【发布时间】:2010-07-29 18:59:26
【问题描述】:
我正在使用 Access 2007 创建一个 SQL 查询来连接两个表。我能够做到这一点,但是我没有第二个表中的列为 NULL 的行;我只有在第二个表中有匹配信息的行。我试图做一个 LEFT JOIN 但 Access 不喜欢这样。相反,我试图为我的查询创建一个更好的“加入/开启”(见下文),但现在我收到“FROM 子句中的语法错误”。你知道我做错了什么吗?
SELECT *
FROM dbo_table1 AS t1
JOIN dbo_table2 AS t2
ON (
(t1.id = t2.id) // where the two ids match so the info in table 2 match with table 1
OR
((SELECT COUNT(*) FROM dbo_table2 AS t3 WHERE t1.id = t3.id)=0) // there is no match but I want the row with NULL for the values from the second table
);
【问题讨论】: