admin管理员组文章数量:1026989
SELECT c.LocationNum, c.OwnerNum, o.FirstName, o.LastName
FROM CondoUnit c
JOIN Owner o
ON c.OwnerNum=o.OwnerNum;
Expected to see for every condo locationnum, ownernum, firstname, last name. Access says it is a syntax error
SELECT c.LocationNum, c.OwnerNum, o.FirstName, o.LastName
FROM CondoUnit c
JOIN Owner o
ON c.OwnerNum=o.OwnerNum;
Expected to see for every condo locationnum, ownernum, firstname, last name. Access says it is a syntax error
Share Improve this question edited Nov 18, 2024 at 22:37 Bergi 667k161 gold badges1k silver badges1.5k bronze badges asked Nov 18, 2024 at 22:10 Diana GrigoriantsDiana Grigoriants 211 bronze badge 5 |1 Answer
Reset to default 3The Access database engine does not accept JOIN
alone and complains "Syntax Error in FROM clause" when encountering it. You must always specify the type of join you want (INNER
, LEFT
, or RIGHT
).
I think you want INNER JOIN
:
SELECT c.LocationNum, c.OwnerNum, o.FirstName, o.LastName
FROM CondoUnit c
INNER JOIN Owner o
ON c.OwnerNum=o.OwnerNum;
SELECT c.LocationNum, c.OwnerNum, o.FirstName, o.LastName
FROM CondoUnit c
JOIN Owner o
ON c.OwnerNum=o.OwnerNum;
Expected to see for every condo locationnum, ownernum, firstname, last name. Access says it is a syntax error
SELECT c.LocationNum, c.OwnerNum, o.FirstName, o.LastName
FROM CondoUnit c
JOIN Owner o
ON c.OwnerNum=o.OwnerNum;
Expected to see for every condo locationnum, ownernum, firstname, last name. Access says it is a syntax error
Share Improve this question edited Nov 18, 2024 at 22:37 Bergi 667k161 gold badges1k silver badges1.5k bronze badges asked Nov 18, 2024 at 22:10 Diana GrigoriantsDiana Grigoriants 211 bronze badge 5- 1 Please tag or mention exactly which SQL syntax this is. – phuzi Commented Nov 18, 2024 at 22:23
- 1 Not to familiar with the access sql dialect. But what happens if you leave out the 'c' and '0' and use the table names instead? Furter more... doesn't access give a hint on what is going on? Just the mention of a syntax error? – Peter Commented Nov 18, 2024 at 22:25
-
1
I think you're missing the
AS
for the table aliases...FROM CondoUnit AS c JOIN Owner AS o
- support.microsoft/en-gb/office/… – phuzi Commented Nov 18, 2024 at 22:31 - can you also check just by selecting the columns on their own i.e without joining and check if the table name and each column name is the expected one? – samhita Commented Nov 18, 2024 at 22:52
-
2
@phuzi No.
MS-Access
also support alias without keywordAs
. Problem is in join type not defined. In access there are only three join type ` (1) Inner Join (2) Left Join (3) Right Join. So, OP must specify join type. – Harun24hr Commented Nov 19, 2024 at 7:49
1 Answer
Reset to default 3The Access database engine does not accept JOIN
alone and complains "Syntax Error in FROM clause" when encountering it. You must always specify the type of join you want (INNER
, LEFT
, or RIGHT
).
I think you want INNER JOIN
:
SELECT c.LocationNum, c.OwnerNum, o.FirstName, o.LastName
FROM CondoUnit c
INNER JOIN Owner o
ON c.OwnerNum=o.OwnerNum;
本文标签: sqlI have a syntax error and I can39t get whyStack Overflow
版权声明:本文标题:sql - I have a syntax error and I can't get why - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745591353a2157906.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
AS
for the table aliases...FROM CondoUnit AS c JOIN Owner AS o
- support.microsoft/en-gb/office/… – phuzi Commented Nov 18, 2024 at 22:31MS-Access
also support alias without keywordAs
. Problem is in join type not defined. In access there are only three join type ` (1) Inner Join (2) Left Join (3) Right Join. So, OP must specify join type. – Harun24hr Commented Nov 19, 2024 at 7:49