CASE WHEN
的语法:
SELECT c.bank_account,
c.id,
css.value,
b.name bankName,
d.name branceName,
CASE
WHEN css.value = '1' THEN d.name
WHEN css.value = '2' THEN b.name || d.name
ELSE d.name
END AS qualifiedBankName
FROM ff_comp_bank c
LEFT JOIN ff_bank_branch d ON c.branch_id = d.id
LEFT JOIN ff_bank b ON b.id = d.bank_id
LEFT JOIN ff_sys_setting css ON css.name = 'BANK_BRANCH_NAME'
WHERE c.company_id = '2';
晚上的火车,回家过年了... D4652