Link to home
Start Free TrialLog in
Avatar of ibozc
ibozc

asked on

SQL INNER JOIN syntax error.

I have this SQL query that does not execute because there is a problem in it. I cannot see a syntax issue with it. If you can please help. Thank you.

SELECT  B.*,  S.*,  M.[File Closing Date]
FROM BoxNumbers AS B  INNER JOIN StorageBoxesTable AS S ON B.IronMountain = S.newboxnumber
INNER JOIN MasterFileList AS M ON S.FileNumber = M.[File Number]
WHERE ((S.OldBoxNumber)<>(B.OldRecall));
Avatar of G Godwin
G Godwin
Flag of United States of America image

What is the error?
-G
Avatar of ibozc
ibozc

ASKER

Syntax Error (missing operator) in query expressions B.IronMountain = S.newboxnumber
INNER JOIN MasterFileList AS M ON S.FileNumber = M.[File Number]
M.[File Number] could be wrong. Check your column name, whether it have space inbetween. It may be M.FileNumber

»Raj
Same applies for M.[File Closing Date]

»Raj
Avatar of ibozc

ASKER

they are correct.
Avatar of ibozc

ASKER

I may add that B.IronMountain, S.FileNumber and  S.newboxnumber may have multiple entries and only M.[File Number] is unique. Would that make any difference?
How about the extra parentheses in your where?


SELECT  B.*,  S.*,  M.[File Closing Date]
FROM BoxNumbers AS B  INNER JOIN StorageBoxesTable AS S ON B.IronMountain = S.newboxnumber
INNER JOIN MasterFileList AS M ON S.FileNumber = M.[File Number]
WHERE (S.OldBoxNumber<>B.OldRecall);
>>> I may add that B.IronMountain, S.FileNumber and  S.newboxnumber may have multiple entries and only M.[File Number] is unique. Would that make any difference?
No, that would just produce a larger result set.
-G
SOLUTION
Avatar of G Godwin
G Godwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Are these tables or views?  If view, maybe an error in the view?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ibozc

ASKER

Thank you guys, that last one worked perfectly.