mysql将0和1转换为男和女, 并且要根据男女作为关键字来查询?

mysql将0和1转换为男和女, 并且要根据男女作为关键字来查询?,第1张

update 2次就行了,update 表 set 列名=男 where 列名=0,一次类推写女,2次替换后,这个字段就可以写WHERE 列名='男'了。你的第二个小问题有点奇怪啊,转换后值自然可以作为关键字来查询了

select score,sex,name,count(*) from table group by sex order by score desc

score 分数 sex性别 name名字

---------------------------------------------------------

select score,sex,name,max(score) from table group by sex

这样试试?或者你union all试试

select name,sex,score from  table where sex='f' order by score desc union all

select name,sex,score from  table where sex='m' order by score desc limit 2


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/7531683.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-06
下一篇2023-04-06

发表评论

登录后才能评论

评论列表(0条)

    保存