Hi, I need to insert rows into table1 from table2 and table3 but I don't want to insert repeated combinations of col2, col3. So, table1 has the primary key col2, col3.
This the table1:
create table table1(
col1 int not null,
col2 int not null,
col3 int not null,
constraint PK_table1 primary key (col2, col3)
)
This is my "insert" code:
INSERT INTO table1
SELECT table2.col1,table2.col2, table3.col3
FROM table2, table3
WHERE table2.col1 = table3.col1
Wich conditions shoud i add to this code?
Thanks.
fmilano.If Col2 and Col3 is controlled by Primary key then it will be taken care and if any data is added will be errored.|||To be erroed is what I want to avoid. So, I want to filter this rows by columns col2 and col3.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment