Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 mysql
Index -> Programming, PHP -> PHP Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
octopi




PostPosted: Mon Jun 05, 2006 6:35 pm   Post subject: mysql

hey, I need a little help, lets see if anyone knows the answer.

I have two tables,
one named 'p' with fields p_id, and p_name
the other 'f' with f_id, p_id, f_name

I need to insert a row into f, I know the following information p_name, and f_name is there anyway (using only mysql) to do this?

basically I need to find out the p_id from from the p_name, adn then insert this value into 'f' along with f_name.

(I want to do this with just mysql if possible), I don't want to use php to first select the value, and then use that and insert it.

So does anyone know if you can do this?
Sponsor
Sponsor
Sponsor
sponsor
octopi




PostPosted: Mon Jun 05, 2006 7:02 pm   Post subject: (No subject)

I figured it out, if anyones interested here was the anwser (its more complicated than the simplified version I showed before)

code:
insert into 14_found (p_id,b_isbn,b_floor,userid) select p_id, '{$b_isbn}','{$b_floor}','{$s_email}' from 14_pieces where p_name='{$p_name}'


basically, I just needed to add a select statemtent into the insert, and use single qoutes to specify the stuff that was no part of the select that needed to be inserted.
Display posts from previous:   
   Index -> Programming, PHP -> PHP Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: