Sql 响应为空的查询输入null

Sql 响应为空的查询输入null,sql,Sql,我需要制定一个查询,然后卡住。需要有关WHERE x=x的帮助,但如果没有,请输入null或继续 例如 SELECT a.value1, a.value2, b.vlaue1, b.value2, c.value1 FROM columnX a, columnY b, columnZ c WHERE a.value1 = b.value3 and b.value2 = c.value4 and c.value1 = a.va

我需要制定一个查询,然后卡住。需要有关WHERE x=x的帮助,但如果没有,请输入null或继续

例如

SELECT
    a.value1, a.value2,
    b.vlaue1, b.value2,
    c.value1
FROM
    columnX a,
    columnY b,
    columnZ c
WHERE
    a.value1 = b.value3
    and b.value2 = c.value4
    and c.value1 = a.value5
        or c.value1 is null

我需要c.value1的最后一个WHERE为=进行检查,或者如果没有值,则输入空值。现在它似乎阻塞和循环。

使用连接语法,C的左连接:

SELECT
    a.value1, a.value2,
    b.vlaue1, b.value2,
    c.value1
FROM columnX a
INNER JOIN columnY b
  on a.value1 = b.value3
LEFT JOIN columnZ c
  on b.value2 = c.value4
  and c.value1 = a.value5

推广explict
JOIN
sintaxis的使用,Aaron Bertrand写了一篇关于它的好文章。你真的有名为columnX等的表和名为value1等的列吗?太可怕了!谢谢,左边的加入似乎就是答案。我曾尝试加入,但在看到回应和进一步研究后,我明白了原因。