Search code examples
mysqlsqlmysql-error-1052

1052 - Column 'typeid' in field list is ambiguous


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


Solution

  • 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