如何读取数据两个表的比较



我有两个表,表1包含10个普通用户,表2包含3个vip用户用户名(与表1相同)现在我如何使用sql获得所有7个非vip用户的数据?平台:sqlite数据库Android

如果您能在问题中提供数据库平台和实际的表模式,那就太好了。没有这些信息就需要人们做出假设。不管怎样,我认为它应该是这样的。

select *
from table1
where not exists(select * from table2 where table2.username = table1.username)

类似于

SELECT * from Table1
WHERE user_id
NOT IN (SELECT user_id from Table2);

翻译为:选择表1中user_id不存在的所有user_id's from Table2

最新更新