gpt4 book ai didi

php - 如何在Select查询中使用IF或Case语句?

转载 作者:行者123 更新时间:2023-11-29 16:06:07 25 4
gpt4 key购买 nike

我正在尝试从数据库中获取某些情况下的数据,因为在代码级别上它会在页面上产生巨大的负载。

我使用以下查询来执行此操作:

Select * From users If user_status='active' and user_group=2 on case 'student' and user_group=3 on case 'teacher'

如果您有mysql经验,请帮我解决我的问题?

最佳答案

SELECT IF(user_status='active' and user_group=2, 'student', ''), IF(user_status='active' and user_group=3, 'teacher', '') FROM users

关于php - 如何在Select查询中使用IF或Case语句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55730562/

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