
sql查询 两个字段 至少其中一个不为空的结果集
姓名年龄性别张三21男李四22null王五null男李平nullnull要求查出性别和年龄至少有一列不为空的结果集,在线等,急!谢谢大家...
姓名 年龄 性别
张三 21 男
李四 22 null
王五 null 男
李平 null null
要求查出性别和年龄至少有一列不为空的结果集,在线等,急!谢谢大家 展开
张三 21 男
李四 22 null
王五 null 男
李平 null null
要求查出性别和年龄至少有一列不为空的结果集,在线等,急!谢谢大家 展开
5个回答
展开全部
select * from 表 where (性别 is not null or 年龄 is not null) and (性别 is not null and 年龄 is not null)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select * from 表 where not(性别 is null and 年龄 is null);
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select * from 表 where (性别 is not null AND 年龄 is null ) OR (年龄 is not null AND 性别 is null)
这样呢?
这样呢?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select * from 表 where 性别 is not null and 年龄 is null
union
select * from 表 where 性别 is null and 年龄 is not null
union
select * from 表 where 性别 is null and 年龄 is not null
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select * from 表 where 性别 is not null or 年龄 is not null;
追问
这个不对,这个语句会把年龄和性别都为空的结果也列出来
追答
select * from 表 where 性别 'null' or 年龄 'null';
你那列里面不会存的是'null'这个字符吧。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询