每个用户都有一个包含多个记录的能,其中一些记录是空的,
username address
erick
erick
samara
samara New York
denis
denis
expected result:
erick
denis如何编写查询检索表中没有地址值的用户
我试过了,但根本不起作用
“从table_name中选择用户名,其中地址是按用户名分组的”--这也是返回"samara“的,它已经得到了带有地址的记录不是null
发布于 2021-01-21 12:00:03
您可以通过使用来选择"NULL作为地址“的用户,其中地址为空,并且可以通过使用distinct为每个用户选择一行。不需要使用group子句。
select distinct username from table_name where address is null
and username not in (select username from table_name where address is not null)https://stackoverflow.com/questions/65826805
复制相似问题