1052 - Column 'typeid' in field list is ambiguous

stackoverflow002 picture stackoverflow002 · Dec 12, 2012 · Viewed 7.6k times · Source
select id,pubdate, typeid,aid,jobname,jobdepart,jobplace,jobnumber,jobcontact from
  archives right join jobrt on id=aid where typeid=19

1, table archives have fileds: id,pubdate,typeid...

2, table jobrt have fields:aid,jobname,jobdepart,jobplace,jobnumber,jobcontact, typeid..

3, id=aid

now, i want to select out the id column the jobname,jobplace comlumns when typeid=19,..

thank you

Answer

John Woo picture John Woo · Dec 12, 2012

since two tables: archives and jobrt contains columnName typeID, you need to specify the tableName where the value came from, eg

SELECT    id
        , pubdate
        , jobrt.typeid
        , aid
        , jobname
        , jobdepart
        , jobplace
        , jobnumber
        , jobcontact
FROM    archives
        RIGHT JOIN jobrt
            ON archives.id = jobrt.aid
WHERE   jobrt.typeid = 19