假如说有一张test表 含有字段 id,name,如果id相同的情况下查询出name不为空的数据,请问sql怎么写

如题所述

select distinct(id) from table where name !=''

温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-02-28
select id,name from test where id = 1 and name is not null

追问

我的意思是当id相同的情况下查询出那么不为空的数据,并不是说id就一定等于1

追答select id,name from test where name is not null group by id,name

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网