hoverinc Posted January 31, 2011 Share Posted January 31, 2011 Hello everybody i am trying this to insert records from 2tables where field of table 1=field of table 2 because i wanto eliminate non matching data in both tables that's i am creating a third table, need help please INSERT INTO newtable(Field) SELECT Field,Field FROM Table1.Field,Table2.Field WHERE Table1.Field=Table2.Field Link to comment https://forums.phpfreaks.com/topic/226213-insert-data-from-2tables/ Share on other sites More sharing options...
bh Posted January 31, 2011 Share Posted January 31, 2011 Hi, Whats your question? insert...select INSERT INTO tbl_temp2 (fld_id) SELECT tbl_temp1.fld_order_id FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;[/color] Why do you select your "Field" column twice? Link to comment https://forums.phpfreaks.com/topic/226213-insert-data-from-2tables/#findComment-1167760 Share on other sites More sharing options...
hoverinc Posted January 31, 2011 Author Share Posted January 31, 2011 Hi, Whats your question? insert...select INSERT INTO tbl_temp2 (fld_id) SELECT tbl_temp1.fld_order_id FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;[/color] Why do you select your "Field" column twice? THANKS for you reply I was intending to take unique records from a table, instead of deleting now i used this code Create table tmp_tbl as select Distinct fld from tbl; This solved the problem, because i took unique records and inserted them into another table, and then from the tmp_tbl i can use the unique data. Link to comment https://forums.phpfreaks.com/topic/226213-insert-data-from-2tables/#findComment-1167817 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.