此场景的 SQL 语句是什么?
tbl_user_account
id INT(11)
name varchar(100)
username varchar(25)
password varchar(25)
active int(1)
_____________________________________
|id|name | username|password |active|
_____________________________________
|1 |John | jhon123 | p@ssw0rd | 1 |
|2 |Maria| maria321| p@ss | 0 |
我想获取所有记录,但事件字段必须输出 如果为 1,则为"is";如果为 0,则为“否”
我想要这个输出:
<小时/>|id|name | username|password |active|
_____________________________________
|1 |John | jhon123 | p@ssw0rd | Yes |
|2 |Maria| maria321| p@ss | No |
我需要创建一个函数还是只是一个 if 语句?
最佳答案
试试这个:
select id, name, username, password, if (active >0, "YES", "NO") from table_name
关于mysql - if语句,修改输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9730510/