warrenk Posted February 12, 2007 Share Posted February 12, 2007 I am trying to insert records from tableA into tableB if the records do not exist in tableB. Here is my sql statement... INSERT INTO str_a1table2( `brands_url` , `brand_name` , `product_url` , `product_name` , `price` ) SELECT `str_a1table1.brands_url` , `str_a1table1.brand_name` , `str_a1table1.product_url` , `str_a1table1.product_name` FROM str_a1table1 WHERE str_a1table1.brands_url <> str_a1table2.brands_url AND str_a1table1.brand_name <> str_a1table2.brand_name AND str_a1table1.product_url <> str_a1table2.product_url AND str_a1table1.product_name <> str_a1table2.product_name I keep getting syntax errors. Any help greatly appreciated! Thanks, Warren Link to comment https://forums.phpfreaks.com/topic/38094-sql-insert-question/ Share on other sites More sharing options...
artacus Posted February 13, 2007 Share Posted February 13, 2007 Think of the INSERT INTO and SELECT as two totally different statements. Well at least the select has to work on its own. You can't have table2 in your select because you haven't joined it. Get the Select part working and add the INSERT statement after that. Link to comment https://forums.phpfreaks.com/topic/38094-sql-insert-question/#findComment-183431 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.