insert values from one table to another table

Here you can post the doubts and informations of Database design in MYSql , MYSql programming, MYSql database concepts.

insert values from one table to another table

New postby nimi on Sat Nov 07, 2009 1:35 pm

Hi...
I want to insert particular field values from one table to another but only if they do not already exist in that table.
How to do that?
nimi
Newbee
Newbee
 
Posts: 23
Joined: Sat Apr 05, 2008 5:40 pm


Re: insert values from one table to another table

New postby rekha on Sat Nov 07, 2009 4:11 pm

You have to put the condition to check for duplicates in the select query.

Code: Select all
INSERT INTO tbl_temp2 (fld_id)
  SELECT tbl_temp1.fld_order_id
  FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;
rekha
Enthusiast
Enthusiast
 
Posts: 191
Joined: Sat Sep 22, 2007 1:39 pm


Return to MYSql

Who is online

Users browsing this forum: MSN [Bot] and 1 guest