79415692

Date: 2025-02-05 17:49:49
Score: 0.5
Natty:
Report link

With only mykey conflicting

To solve the problem you explicitely ask for in your question ("Why does it give me a syntax error?"), @Alex Poole's comment is the answer: GO is not Oracle, just remove it.

But then you will get what Krzysztof Madejski's answers for:
the USING will work as long as the join column (mykey) is the only column which has the same name over multiple tables:

create table Temptable as
SELECT *
FROM
table_1
INNER JOIN table_2 USING (mykey)
INNER JOIN table_3 USING (mykey)
WHERE table_1.A_FIELD = 'Some Selection';

To remove other columns

If you've got other columns with a duplicate name over two tables, you'll have to first make them unique:

The PIVOT way
WITH table_3_r as (SELECT * FROM table_3 PIVOT (max(1) FOR (a_field) IN ()))
SELECT *
FROM
table_1
INNER JOIN table_2 USING (mykey)
INNER JOIN table_3_r USING (mykey)
WHERE table_1.A_FIELD = 'Some Selection';

Here in a fiddle.

Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • User mentioned (1): @Alex
  • Low reputation (0.5):
Posted by: Guillaume Outters