l******e 发帖数: 12192 | 1 table A有fields: id, book, title
每个id可能有100K books
table B也有id, book
现在我想把table A里的数据和table B一致:相同的id,B没有的books,就删掉,B有的
就添加
其实不同的可能就几个,有没有什么高效的SQL写法? | b*******u 发帖数: 3 | 2 考虑考虑
minus, exist, not exist
吧
有的
【在 l******e 的大作中提到】 : table A有fields: id, book, title : 每个id可能有100K books : table B也有id, book : 现在我想把table A里的数据和table B一致:相同的id,B没有的books,就删掉,B有的 : 就添加 : 其实不同的可能就几个,有没有什么高效的SQL写法?
| d*h 发帖数: 2347 | 3 select *
from table_a a
left join table_b b
on a.id = b.id
and a.book = b.book
where b.book = null;
有的
【在 l******e 的大作中提到】 : table A有fields: id, book, title : 每个id可能有100K books : table B也有id, book : 现在我想把table A里的数据和table B一致:相同的id,B没有的books,就删掉,B有的 : 就添加 : 其实不同的可能就几个,有没有什么高效的SQL写法?
|
|