Trium918 Posted April 14, 2007 Share Posted April 14, 2007 What would be the syntax for inserting data into two different database tables? Maybe something like this <? $result = mysql_query("insert into members_info,members_address values"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/46962-i-need-a-syntax/ Share on other sites More sharing options...
Trium918 Posted April 14, 2007 Author Share Posted April 14, 2007 Somebody knows something!!! Quote Link to comment https://forums.phpfreaks.com/topic/46962-i-need-a-syntax/#findComment-229021 Share on other sites More sharing options...
clown[NOR] Posted April 14, 2007 Share Posted April 14, 2007 maybe something like this? INSERT INTO table1,table2 ('field1', 'field2', 'field3') VALUES ('value1', 'value2', 'value3') Quote Link to comment https://forums.phpfreaks.com/topic/46962-i-need-a-syntax/#findComment-229114 Share on other sites More sharing options...
bubblegum.anarchy Posted April 14, 2007 Share Posted April 14, 2007 I am not sure inserting into more than one table at a time with the one query is possible.. EDIT just use two queries... how else are you going to link the members_address without an auto increment id of the members_info? Quote Link to comment https://forums.phpfreaks.com/topic/46962-i-need-a-syntax/#findComment-229118 Share on other sites More sharing options...
Ekate Posted April 15, 2007 Share Posted April 15, 2007 as I correctly understood you need to insert data in two tables or not insert nothing. Probably in this case you can use transaction. the sequence is following: begin transaction tr_name insert into table1... insert into table2... commit transaction tr_name you should check the syntax of transactions in MySQL Quote Link to comment https://forums.phpfreaks.com/topic/46962-i-need-a-syntax/#findComment-229580 Share on other sites More sharing options...
fenway Posted April 20, 2007 Share Posted April 20, 2007 You can't insert into more than one table at a time. Quote Link to comment https://forums.phpfreaks.com/topic/46962-i-need-a-syntax/#findComment-233933 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.