dsp15140275697 2013-09-08 17:37
浏览 14

Mysql在查询之间多次

I need to show age result difference like age between 5 and 10 AND age between 50 and 55

I have used this query

$sql = "select name,age from tbl where (age BETWEEN 5 AND 10) OR (age BETWEEN 50 AND 55)";
$res = mysql_query($sql)

Thanks.

  • 写回答

1条回答 默认 最新

  • doujiena0025 2013-09-08 17:38
    关注
    select name,age, case when age BETWEEN 5 AND 10
                          then '5-10'
                          else '50-55'
                    end as age_between
    from tbl 
    where ( age BETWEEN 5 AND 10)  
    or (age BETWEEN 50 AND 55)
    

    BTW it would be better to store the birthdate. Then you don't have to set the age.

    评论

报告相同问题?

悬赏问题

  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错