I have tricky SQL query to create, which if possible will save me a lot of PHP code.
So I have an HTML form where a visitor can create a user account with the fields name, email, password, interests.
For the name, email and password I have a simple INSERT query to enter this info into the database users, however the interests field can have multiple entries so this data is stored in many-to-many join tables (interests, user_interests).
In order for me enter these interests in the table user_interests, I need to obtain the User ID number which was auto-incremented from the initial INSERT query plus loop over another INSERT for each "interest" the user has chosen. Can I accomplish this all in one SQL query?
LAST_INSERT_ID()will be useful: dev.mysql.com/doc/refman/5.1/en/…