我的“用户”表中有一个用户名列表(带有一个名为“用户名”的列)+ 其他信息。
我的较小的“recentusers”表中还有另一个用户名列表(带有一个名为“用户名”的列)。
我如何创建一个 mysql 查询来获取“users”表中但不在“recentusers”表中的所有用户名?
我知道这可能非常简单,但我们将不胜感激!
最佳答案
select username from users where username not in (select username from recentusers)
然后在第一个用户名之后添加您要选择的其他信息。
正如 OMG Ponies 所指出的,此查询的运行速度与使用 Left Join or Is null. 一样快
关于php - MySQL 基础问题 : how to get rows from one table that are not in another table?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1785799/