我有一个看起来像这样的查询:
SELECT 'asdf', '123' ...
FROM table1
LEFT JOIN table2
on
(
condition1
)
LEFT JOIN table3
on
(
condition2
)
where
(
main_condition
)
现在的问题是,我也需要有条件地包含table1
。我试过这个:
..
..
FROM table1
on
(
new_condition
)
..
..
但这行不通。请帮忙。
编辑(新发现):在这篇文章(http://blog.sqlauthority.com/2010/07/20/sql-server-select-from-dual-dual-equivalent/)中,我发现了这段代码:
SELECT 1 as i, f.bar, f.jar FROM dual LEFT JOIN foo AS f on f.bar = 1 WHERE dual.dummy = ‘X’
UNION
SELECT 2 as i, f.bar, f.jar FROM dual LEFT JOIN foo AS f on f.bar = 2 WHERE dual.dummy = ‘X’
我确定这与我正在尝试做的事情没有直接关系,但是JOIN
桌子可以DUAL
喜欢这样吗?