当前页面: 开发资料首页 → JSP 专题 → 小第遇到个很困难的sql语句...请高手帮忙?????谢谢了
小第遇到个很困难的sql语句...请高手帮忙?????谢谢了
摘要: 小第遇到个很困难的sql语句...请高手帮忙?????谢谢了
表:leaveword (投票的表)
id sms time
1 1 ..
2 1#2 ..
3 1,2 ..
4 3 ..
5 4 ..
统计投 1和2和3和4的数量并排序怎么写
采用存储过程吧,单个语句估计难的
1#2 1,2有什么区别呀,还有其他的间隔符吗?
有比如# * +没了,好不算
只有1234吗?
用4条语句:
select count(*) from leaveword where sms like '%1%'
select count(*) from leaveword where sms like '%2%'
select count(*) from leaveword where sms like '%3%'
select count(*) from leaveword where sms like '%4%'
自己排序
要一次完成
#*,什么意思?
select ry,sl from (
select count(*) as sl,'1' as ry from leaveword where sms like '%1%'
union
select count(*) as sl,'2' as ry from leaveword where sms like '%2%'
union
select count(*) as sl,'3' as ry from leaveword where sms like '%3%'
union
select count(*) as sl,'4' as ry from leaveword where sms like '%4%'
) order by sl desc
这叫不叫一条语句?
是不是一次完成?
我去决了,谢谢大家可惜分少.要不都给点分了,
多谢changzhang