gpt4 book ai didi

php - Mysql在查询之间多次

转载 作者:行者123 更新时间:2023-11-30 01:19:42 24 4
gpt4 key购买 nike

我需要显示年龄结果差异,例如年龄在 5 到 10 岁之间并且年龄在 50 到 55 岁之间

我使用过这个查询

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

谢谢。

最佳答案

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)

顺便说一句,最好存储生日。那么您就不必设置年龄。

关于php - Mysql在查询之间多次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18686654/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com