Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要显示年龄结果差异,例如 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)
顺便说一句,最好存储生日。然后你不必设置年龄。