SQL INNER JOIN duplicate columns

Viewed 109

I am trying to return some columns from 2 tables which share an ID column using the following browser database query system, which reads from the tables shown on this webpage. I believe the way to do this is by using INNER JOIN (e.g. see this guide).

SELECT  sami_dr2.DR2Sample.CATID,
        sami_dr2.DR2Sample.Mstar,
        sami_dr2.StellarKinematics.PA_STELKIN
FROM    sami_dr2.DR2Sample INNER JOIN sami_dr2.StellarKinematics
ON      sami_dr2.DR2Sample.CATID = sami_dr2.StellarKinematics.CATID;

However, when I run this query I get the error message:

sql: Duplicate columns are not supported. Try using an alias for those columns within the SELECT clause e.g., SELECT t1.CATAID, t2.CATAID becomes SELECT t1.CATAID as t1_CATAID, t2.CATAID as t2_CATAID

But as far as I'm aware the whole point of using the INNER JOIN is to remove duplications as I'm not returning sami_dr2.StellarKinematics.CATID in my output table, only sami_dr2.DR2Sample.CATID.

I've also found that using SELECT sami_dr2.DR2Sample.CATID as ID_1, sami_dr2.StellarKinematics.CATID as ID_2 in the selction doesn't fix the problem either.

Any help on this would be greatly appreciated!

0 Answers
Related