Reputation: 27
I have tried all answers but none are working. But the code is working when I use only one column either State or LGA. When I combine the two as you can find in the query below I get an error:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ','.
Please help me out
Code:
SELECT [Community].[CommunityID],
[Community].[CommunityName],
[Community].[StateID],
[StateName] AS [StateName],
[Community.LGAID],
[LGA].[LGName] AS [LGName]
FROM [Community], [State]
WHERE ([Community].[StateID] = [State].[StateID], [LGA]
WHERE [Community].[LGAID] = [LGA].[LGAID]
Upvotes: 0
Views: 177
Reputation: 13959
I think you are trying to do join and it is syntax error near to LGA, you can convert your code as below to provide explicit join conditions
SELECT [Community].[CommunityID], [Community].[CommunityName], [Community].[StateID], [StateName] AS [StateName], [Community].[LGAID], [LGA].[LGName] AS [LGName]
FROM [Community] JOIN [State] ON [Community].[StateID] = [State].[StateID]
JOIN [LGA] ON [Community].[LGAID]=[LGA].[LGAID]
Upvotes: 1