对于某些数据库表中用0,1来表示性别,当需要查询结果显示男或者女时,可以使用case when语句:
SELECT s.name 姓名, (CASE s.gender WHEN 1 THEN '男' WHEN 0 THEN '女' END) 性别,
s.birth 生日 FROM students s INNER JOIN classinfo c
ON s.cid=c.id WHERE c.name = 'java后端' ORDER BY birth DESC;
对于某些数据库表中用0,1来表示性别,当需要查询结果显示男或者女时,可以使用case when语句:
SELECT s.name 姓名, (CASE s.gender WHEN 1 THEN '男' WHEN 0 THEN '女' END) 性别,
s.birth 生日 FROM students s INNER JOIN classinfo c
ON s.cid=c.id WHERE c.name = 'java后端' ORDER BY birth DESC;