![]() |
Insert data into two tables with one query
Hey,
Can you insert data into two tables using only one query? I know you can SELECT and UPDATE two tables with one query, which is why I assumed you could do it with INSERT, but upon trying and looking at sites provided by Google, I came up with nothing... which is where I come to ask you lot :PI tried this: PHP Code:
Any ideas? Cheers! |
Just use mysqli_query and have two INSERT commands.
|
I don't believe you can do it for an
INSERT statement, but you can put them in a TRIGGER which can then be executed using one call to it. If you were looking for an easy solution then I think you're out of luck, I'm afraid. |
Ah well, nevermind. Thanks anyway.
I've not read much into MySQLi, but I probably should. |
From the manual
"INSERT inserts new rows into an existing table. " notice the use of the singular table. |
Yeh, try the multi insert function in MySQLi Just be careful though as it allows anyone to add some pretty nasty queries if they can somehow introduce a semi-colon into your query.
|
| All times are GMT. The time now is 04:49 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0