尝试创建SQL查询,如果字段条目满足条件,则在读取字段时为空,如果不是,则输入读取的值,它会跳过该行的整个选择。
SELECT a.name, b.age
CASE
WHEN a.birthday = b.birthday THEN vlaue?
WHEN a.birthday != b.birthday THEN skip?
ELSE is null THEN null
END AS birthday
FROM information a, tracking b
WHERE a.name = b.name
因此,如果出生日期匹配或者为空,则输入姓名和年龄,但如果出生日期不匹配,则根本不输入姓名和年龄。
答案 0 :(得分:0)
你应该在哪里使用
SELECT a.name, b.age
CASE
WHEN a.birthday = b.birthday THEN 'value'
ELSE null
END AS birthday
FROM information a
INNER JOIN tracking b ON a.name = b.name
WHERE a.birthday != b.birthday
(你应该使用明确的连接符号..更可读)
或者如果您还不匹配则使用左连接
SELECT a.name, b.age
CASE
WHEN a.birthday = b.birthday THEN 'value'
ELSE null
END AS birthday
FROM information a
LEFT JOIN tracking b ON a.name = b.name
WHERE a.birthday != b.birthday