作者:机加工N_918 | 来源:互联网 | 2023-05-17 13:47
ihavetablenamedchat_userswithcolumns:我有一个名为chat_users的表与列:id|username|status|time_mod
i have table named chat_users
with columns:
我有一个名为chat_users的表与列:
id | username | status | time_mod | views
Here is an example of UPDATE with CASE statement that works brilliantly:
以下是使用CASE语句更新UPDATE的示例:
$db->exec("UPDATE `proba13`.`chat_users`
SET `username` = CASE id
WHEN 4 THEN 'Jie'
WHEN 5 THEN 'Mie'
WHEN 6 THEN 'Pres'
END,
`status` = CASE id
WHEN 4 THEN '1'
WHEN 5 THEN '2'
WHEN 6 THEN '3'
END
WHERE id IN (4,5,6)");
QUESTION: can anybody please give me an example of SELECT with CASE statement on the same table ?
问题:有人可以在同一张桌子上给我一个SELECT with CASE语句的例子吗?
regards and Thank you in advance!
尊敬并提前谢谢!
2 个解决方案