Hi, thanks for reply
No, the insertion will always be successful.
The user is authorized to do this query because he authenticated well. So i don't need to check for his credentials at this point. I only want to get the value of his id, because i don't want the names of the users to appear on the table i make the insertion into.
So my question is:
how do i make an INSERTion into a table which needs to receive a value that is located on another table.
-
/**
-
* User basic information
-
*/
-
Table 1-------------
-
-user_id
-
-user_name
-
-
/**
-
* User extra information
-
*/
-
Table 2------------
-
-user_id
-
-mood
-
-foo
-
-foo2
-
...
-
the first table has the value i need (user_id) to get for the INSERTion on Table 2. I have all the information to be inserted into Table 2 except the user_id which is available from Table 1 by giving the user name.
i could do this to get my job done:
- $resulting_user_id = "SELECT user_id FROM Table1 WHERE user_id = '$user_name'"
and then i would reuse the previos result ($resulting_user_id)to insert all the values:
- "INSERT INTO Table2 (user_id, mood, foo, foo2) VALUES ($resulting_user_id, rest of the values already available)"
for that, i was wondering if i could make the query i posted on my first post, which shrinks all in a single one
if you have any suggestion, please let me know
Thank you
bilibytes