这种方法不起作用,因为它会产生语法错误。
SELECT A.Field1, A.Field2, B.Field3, B.Field4, Field5,
IF(A.SomeField = "","No","Yes") AS Field5;
FROM Atable A, Btable B
WHERE A.Field1 = B.FieldX;
答案 0 :(得分:2)
使用CASE WHEN
SELECT A.Field1, A.Field2, B.Field3, B.Field4,
CASE WHEN A.Field1 = ""
THEN 'NO' ELSE 'YES' END AS Field5
FROM Atable A
JOIN Btable B on B.FieldX = A.Field1