SQL语句查询

、若得到A表中不与B表相同的数据:
SELECT info
FROM A
WHERE (info NOT IN
(SELECT info
FROM B
WHERE b.info = a.info))
或者:
SELECT info
FROM A
WHERE (NOT EXISTS
(SELECT info
FROM B
WHERE b.info = a.info))

2、若得到两个表不同的记录:
SELECT info
FROM A
WHERE (info NOT IN
(SELECT info
FROM B
WHERE b.info = a.info))
UNION ALL
SELECT info
FROM B
WHERE (info NOT IN
(SELECT info
FROM a
WHERE b.info = a.info))


自制库表结构

select top 0 * into 新表 from 旧表




你可能感兴趣的:(sql)