求一个查询效果,关于不满足条件的时候的处理 比如数据库中 一个人员表,其中只有一条性别为男的数据这个时候我以性别为女来查询,自然是查不到数据的但是这个时候我不希望出空记录,我希望能有一条记录,这条记录所有字段都是空。有没有办法做到? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select * from 员工表 where sex=xxxunion allselect null,null,... from 员工表 where not exists(select 1 from 员工表 where sex=xxx) select col1 .. from tb where sex='man'union allselect null as col1.... from tb where (select count(1) from tb where sex='man')=0 if exists(select 1 from 人员表 where 性别 = '女') select * from 人员表 where 性别 = '女'else select null , null , ... from 人员表 select * from 员工表 where sex='女'IF @@ROWCOUNT = 0 SELECT NULL, NULL, NULL, NULL... FROM 员工表 一般都是在显示页面左做处理,Add一个DataRowsql里加一行的做法逻辑不好 求VB+SQL分行书写格式!!! 存储过程中的参数问题 存储过程参数问题 建立帐户的语句怎么写? SQL EXISIT语句的理解 我的存储过程出了如下错误,请高手帮忙,谢谢,特别着急在线等待,谢谢!!! msssq2005乱码问题如何解决呀 极菜问题一个 什么意思:使用ConnectionTimeout之前,确保连接提供程序和数据源支持该属性 sql 2008 反馈解决办法?打开窗口出问题 触发器的问题 sql 2005 导出excel
union all
select null,null,... from 员工表 where not exists(select 1 from 员工表 where sex=xxx)
union all
select null as col1.... from tb where (select count(1) from tb where sex='man')=0
select * from 人员表 where 性别 = '女'
else
select null , null , ... from 人员表
IF @@ROWCOUNT = 0
SELECT NULL, NULL, NULL, NULL... FROM 员工表