mysql
Author |
Message |
octopi
|
Posted: 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
|
|
|
octopi
|
Posted: 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. |
|
|
|
|
|
|
|