Table update

R@Y

New member
Local time
Today, 13:56
Joined
Jul 27, 2007
Messages
2
Hello, gents.

Just a quick question:
I've got two tables.

First one (Master) has 15 rows and about 67k records,
Second one (Update) has 4 of those the first has and about 89k records.
Some of Update's key records are equal to those the Master has.
I need a SQL to insert the records from Update that do not exist in Master.

In other words SQL condition for insert should be smth like this (I used a kind of js):

if (master.row1 <> update.row1){insert}
else{return false}

If you have any ideas, please help.
Thanks in advance,
Ray
 
Try this one to specify the columns for which you want to insert data:

INSERT INTO table_name (column1, column2,...)
VALUES (value1, value2,....)
 
Thanks, kabz, but I need to avoid duplicates while joining these tables.

For example Master table contains:
ROW1(KEY) ROW2 ROW3 ROW4 ROW5
COL1 VALUE1 VALUE2 VALUE3 VALUE4 VALUE5
COL2 VALUE6 VALUE7 VALUE8 VALUE9 VALUE10
COL3 VALUE11 VALUE12 VALUE13 VALUE14 VALUE15
...

Update table contains:
ROW1(KEY) ROW2 ROW3
COL1 VALUE1 VALUE2 VALUE3
COL2 VALUE6 VALUE7 VALUE8
COL3 VALUE11 VALUE12 VALUE13
...

What I need is to insert data from Update table into Master table with validating that Master.ROW1 doesn't contain data equal to Update.ROW1
Please also note that even row is KEY it puts duplicates
 
Last edited:

Users who are viewing this thread

Back
Top Bottom