sql help

一条一条的比对,不能 一条 SQL 完成,要用 procedure 类的
 
INSERT INTO A
(c1, c2)
SELECT t1.c1, t1.c2
FROM B t1
LEFT JOIN A t2 ON t1.c1+t1.c2 = t2.c1+t2.c2
WHERE t2.c1 IS NULL
 
Use in-line query:

select * from a;

COLUMN1 COLUMN2
1 1
2 2

select * from b;

COLUMN1 COLUMN2
1 1
3 3

insert into a(column1, column2)
select column1, column2 from
(select column1, column2 from b where not exists
(select 1 from a where column1 = b.column1 and column2 = b.column2)
);

select * from a;
COLUMN1 COLUMN2
1 1
2 2
3 3
 
码工都是外星人,数据库码工是非银河系外星人。。。
 
ET from HOME!!!!

狗子,换个头像吧?

et-phone-home.jpg
 
晚上心情好就把事情搞定了。白天简直是braindead

这个东西好几个回合的
first auto generate new id in table a if the column 1+ column2 in table b doesn't already exist in table a
add new id in table a to table b
add the columns in table b to table c if the columns in table b doesn't already exist in table c
 
后退
顶部