显示SQL结果为1的文本

时间:2014-06-04 11:55:53

标签: sql

我正在运行以下查询

SELECT accounts.name, accounts_cstm.account_number_c,validated_c,chkcustomer_c, 
users.user_name FROM
accounts_cstm
LEFT OUTER JOIN
accounts
ON accounts.id = accounts_cstm.id_c
LEFT OUTER JOIN
users
ON accounts.assigned_user_id = users.id WHERE accounts.name = '1234'

这是我的网络应用程序enter image description here

中的结果

我想在验证和客户

中显示是或否

1将=是,0将=否

我该怎么做?

2 个答案:

答案 0 :(得分:1)

SELECT accounts.name, accounts_cstm.account_number_c,
    CASE 
        WHEN validated_c = 1
        THEN 'yes' 
        ELSE 'no' 
    END as validated
,chkcustomer_c,users.user_name FROM...

答案 1 :(得分:0)

您可以像这样使用CASE SQL语句:

SELECT 
    […], 
    CASE validated 
        WHEN 1 THEN 'yes' 
        WHEN 0 THEN 'no'
    END
FROM …