我有两张桌子:
答案 0 :(得分:2)
当LEFT JOIN
时,在ON
子句中放置右侧表格条件以获得真正的左连接行为! (在WHERE
时,您会获得定期INNER JOIN
结果。)
SELECT *
FROM req_docs
LEFT OUTER JOIN pers_docs ON req_docs.doc_nid = pers_docs.doc_nid
AND pers_docs.pers_nid = 6
AND pers_docs.expires <= "2009-09-01"
WHERE req_docs.pos_id = "CPT"