I’m stuck with a task I thought simple, and hope it’s actually simple 🙂
I have to insert a string (this is an image file name) in a table, called “images”;
I have another table which is called “projects”;
And a third table with the relation between “images” and “projects” which is called “imagesRel”;
I want to insert the string in “images” and at the same time, assign its auto-incremental id to an auto-incremental id (which I knew before) of the table “projects” in the “imagesRel” as relation.
Which MySql command have I to use?
Is there a JOIN for this insert? I’m stuck because the idImage is yet to be assigned when I make the insert.
By using LAST_INSERT_ID() function
See more here http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html