Ambigous column name

From SQLZoo
schema:gisq

Problem

When more than one table is used (in a JOIN for example) there may be two columns with the same name.

In this example there is a column called name

in bbc and also in cia.

Solutions

  • Include the table name before the column name:
    SELECT bbc.name
      FROM bbc JOIN cia ON bbc.name = cia.name
    
  • Alias at least one of the tables and use that
    SELECT B.name
    FROM bbc B JOIN cia ON B.name = cia.name
SELECT name
  FROM bbc JOIN cia ON bbc.name = cia.name
DataWars, Data Science Practice Projects - LogoDataWars: Practice Data Science/Analysis with +100 Real Life Projects
  • Your server today is: Laa-Laa