我找不到一个直截了当的答案.我的查询是吐出错误的结果,我认为这是因为它没有将“AND”视为实际的连接.
你可以做这样的事情,如果没有,那么正确的做法是什么:
SELECT * from X LEFT JOIN Y ON y.date = x.date AND y.code = x.code
?
这个有可能:
原文链接:https://www.f2er.com/postgresql/192872.htmlThe ON clause is the most general kind of join condition: it takes a Boolean value expression of the same kind as is used in a WHERE clause. A pair of rows from T1 and T2 match if the ON expression evaluates to true for them.
http://www.postgresql.org/docs/9.1/static/queries-table-expressions.html#QUERIES-FROM
你的sql看起来不错.