I'm not totally new to SQL, but am rusty and struggle with MYSQL (using PhPMyAdmin)... looked at this: MySQL insert to multiple tables (relational) and some other related topics, but haven't found an answer. I'm simplifying my example to get the point across.
If you have two tables:
'table1' has: id (primary key, auto-increment), description (text)
'table2' has: id (primary key, auto-increment), title (text), description_id (int)
How do I create a singe INSERT statement so that description_id
is storing the value for table1.id
?
I know there are php ways to do 2 queries but I'd like to do it all in SQL, there must be a way? Should I set up my tables differently? I read something about foreign keys and have no idea if that's applicable.
Thanks!