Question

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

Was it helpful?

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

OTHER TIPS

You should identify what table in the select, something like the following:

select archives.id,archives.pubdate, archives.typeid,aid,jobname,jobdepart,jobplace,jobnumber,jobcontact from
  archives right join jobrt on id=aid where typeid=19
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top