CyberShot Posted December 14, 2010 Share Posted December 14, 2010 I am experimenting with some code. I have an html form that asks for first, last and company name also for home, cell and company phone numbers. I have been trying to insert the values into both tables with one insert query. Something I read online but it doesn't seem to work. If I use one insert query to insert into one table, then it works fine So if I want to insert the values from my form into two tables, do I need to use two insert queries? How is this normally done Quote Link to comment https://forums.phpfreaks.com/topic/221688-inserting-into-two-tables/ Share on other sites More sharing options...
Maq Posted December 14, 2010 Share Posted December 14, 2010 It's bad practice to store the same data in two separate tables, it defeats the purpose of certain design principles. Do you have to do this within 1 query? Quote Link to comment https://forums.phpfreaks.com/topic/221688-inserting-into-two-tables/#findComment-1147424 Share on other sites More sharing options...
CyberShot Posted December 14, 2010 Author Share Posted December 14, 2010 I don't know what you mean when you say the same data in two separate tables. I have table names firs name last name company name table phone home cell company phone my form asks for the information above then I want to insert it. I am having trouble using just one insert query to insert whatever values were filled into the form. Someone else here said that you can't use one query to insert into to tables but I am finding code online for it. Quote Link to comment https://forums.phpfreaks.com/topic/221688-inserting-into-two-tables/#findComment-1147427 Share on other sites More sharing options...
Pikachu2000 Posted December 15, 2010 Share Posted December 15, 2010 You can not use one query to insert into two tables. It really is that simple. Quote Link to comment https://forums.phpfreaks.com/topic/221688-inserting-into-two-tables/#findComment-1147517 Share on other sites More sharing options...
Maq Posted December 15, 2010 Share Posted December 15, 2010 Sorry, I took this as you wanted the same data in two separate tables. I have been trying to insert the values into both tables with one insert query. Quote Link to comment https://forums.phpfreaks.com/topic/221688-inserting-into-two-tables/#findComment-1147705 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.