r/SQLServer • u/Shot-Zookeepergame22 • Dec 11 '25
Question What did I do wrong ?
Hi there , I’m learning SQL and I cannot understand what I did wrong with the code. The left window is my work and the right window is the solution. My eyes hurt trying to figure out what I did wrong . The error keeps stating “incorrect syntax near ‘JOIN’”
0
Upvotes
4
u/SQLBek 1 Dec 11 '25
Semi colons terminate the statement. You copied and pasted such that you have a bunch of semi colons within your statement causing the syntax error
18
u/thejumpingmouse Dec 11 '25
Semicolons should go at the end of the entire select statement. Currently you have them after the join. That ends the select statement so anything after that first semicolon is read as its own statement. If you read it as its own statement you're beginning with Join which is incorrect.
33
u/VladDBA Microsoft MVP Dec 11 '25
Sorry to be blunt, but you literally have a working example on your right half of the screen, you can just compare what the extra thing is that's breaking your query on the left (hint: that squiggly red line is in the vicinity of your issue)
6
u/linkdudesmash Dec 11 '25
If you can’t compare two pieces of code.. sorry just give up
3
u/Silver__1 Dec 11 '25
;
2
u/VinceP312 Dec 11 '25
Wink
2
u/user0987234 Dec 11 '25
May I recommend you use Notepad++ and get the Compare add-in. You will spot the differences easily. Caution with a LLM, Copilot often changes the code even prompted not to do so.
2
u/Firm_Communication99 Dec 11 '25
Go copy this into ChatGPT it is 2025 and you asking Reddit
1
u/Ok-Clerk-8911 Dec 11 '25
Semi colons on lines 11,13,15. Those, you might’ve written the joins sequentially- copy pasting , and accidentally copied the semi colon.
1
u/InterviewImpressive1 Dec 11 '25
You only need 1 semi colon at the end.
1
u/Independent-Fly7241 Dec 11 '25
Why use semicolons in SQL server ssms it says error on line 13 don't know what that is it's been more than a month I finished this data with barra course since then I haven't code much
1
u/LostEstablishment487 Dec 11 '25
Agree with semi colons thing
1
u/[deleted] Dec 12 '25
The extra semi-colons at the end of each table in the join.
1
u/mikeyw17 Dec 12 '25
Semicolon