表:leaveword    (投票的表)    id   sms      time
    1     1        ..
    2     1#2      ..
    3     1,2      ..
    4     3        ..
    5     4        ..统计投 1和2和3和4的数量并排序怎么写

解决方案 »

  1.   

    只有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%'自己排序
      

  2.   

    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
    这叫不叫一条语句?
    是不是一次完成?
      

  3.   

    我去决了,谢谢大家可惜分少.要不都给点分了,
    多谢changzhang