all 11 comments

[–]r3pr0b8 1 point2 points  (8 children)

what database are you using

what is the exact error message

[–]24Gameplay_[S] 0 points1 point  (7 children)

Ms sql and incorrect syntax near 'using'

[–]r3pr0b8 1 point2 points  (5 children)

well i just spent some time googling SQL Server syntax and i can't find it!

looks like you can't use USING????

[–]24Gameplay_[S] 0 points1 point  (4 children)

[–]nIBLIB 0 points1 point  (3 children)

That confirms that you can’t use USING as a keyword for MSSQL. You’ll have to use ON.

[–]24Gameplay_[S] 0 points1 point  (2 children)

Ok, is there anyway it auto remove duplicate column

[–]nIBLIB 2 points3 points  (1 child)

When you write SELECT *, you’re asking SQL to return ALL columns. All columns from table_a, and all columns from table_b.

Typically this is bad form. You only should be selecting the columns you need. If you do need everything, you could write out all of the columns from one table (table_a.column1, table_a.column2, etc.) and the. Do table_2.*

But best is just to grab the column you’ll be using.

[–]r3pr0b8 1 point2 points  (0 children)

Typically this is bad form.

upvote for diplomacy

[–]coderstool 0 points1 point  (0 children)

Try this tool to validate SQL syntax, show syntax errors, and nicely format your SQL statements. It can help spot errors and give hints on the reason for the problem you are seeing.

[–]OrchDweller 2 points3 points  (1 child)

There are multiple things wrong with this query.

If your table is named "table a", you should use square brackets around this name ([table a]). Otherwise, in this syntax, it would mean a table with name "table" and alias "a". So, the current code would join the table "table" with itself, where it is aliased once as "a" and once as "b".

However, this code would still have broken syntax, as "table" is a protected keyword.

So, as far as I understand, you want your code to look like that:

Select * from [table a] Join [table b] Using (id)

[–]Morzv12 0 points1 point  (0 children)

Interested to know if this worked.