i have a table contains two colomns , the first is an ID and the second is text , like this
oneContent (ID,contentText)
i have another table
ioContents (IOID,oneContentID)
and i want to insert this message (” hi man i am WilliamRoma”) into the oneContent and then link it in the ioContents to the IOID =3
i can do that by inserting the message first in the oneContent table and then insert its ID to the ioContents , but how can i get its ID ? ? ? ,
one way to doing it is
SELECT ID FROM oneContent WHERE contentText = "hi man i am WilliamRoma"
but this is a bad way i think , what do u suggest that after inserting the message ,get its id?
ever ID is auto increment
Look here: http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html
I think you want
LAST_INSERT_ID()