当前位置:编程学习 > C#/ASP.NET >>

我新手,我想把下面这四个sql查询语句,写成一句,请问怎么写

select count( t.pscode) from t_info_dgiinfo t where t.pscode like '4101%' 
select count( t.pscode) from t_info_dgiinfo t where t.pscode like '4102%'
select count( t.pscode) from t_info_dgiinfo t where t.pscode like '4103%'
select count( t.pscode) from t_info_dgiinfo t where t.pscode like '4104%' --------------------编程问答-------------------- select count( t.pscode) from t_info_dgiinfo t where t.pscode like '410%' --------------------编程问答-------------------- select count( t.pscode) from t_info_dgiinfo t where t.pscode like '410[1-4]%'  --------------------编程问答-------------------- select count(t.pscode) from t_info_dgiinfo t where t.pscode like '410%' --------------------编程问答--------------------

你需要的查询4个结果吧. 这四个值应该不同吧, 直接用4个语句多方便, 如果说合成一个分4行显示也可以, 不过没什么必要吧.

合成4行的语句.

select count( t.pscode) from t_info_dgiinfo t where t.pscode like '4101%'  
union
select count( t.pscode) from t_info_dgiinfo t where t.pscode like '4102%'
union
select count( t.pscode) from t_info_dgiinfo t where t.pscode like '4103%'
union
select count( t.pscode) from t_info_dgiinfo t where t.pscode like '4104%'
补充:.NET技术 ,  非技术区
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,