Jump to content

INSERT data from 2tables


hoverinc

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.