user2734979
user2734979

Reputation: 11

unknown column "___" in field list

I have two tables in my ty019 database namely tya019 and tya0191. I want to join csa, name, totm from tya019 and cell_n, place from tya0191 and rno of both tables (which is primary key of both of them). Name column is present in both the tables.

When I type

select name.tya019, totm.tya019, csa.tya019, cell_n.tya0191, place.tya0191 
  from tya019,tya0191 
 where rno.tya019=rno.tyao191 

I get this error

Unknown column 'name.tya019' in 'field list'.

Where I might have gone wrong? Please help me.

Upvotes: 1

Views: 782

Answers (1)

peterm
peterm

Reputation: 92795

You wrote it backwards. It should be table_name.column_name rather than column_name.table_name

Besides that

  • aliases might help make your queries more readable by reducing repetitive long identifiers
  • use ANSI explicit JOIN syntax rather than old implicit (coma) syntax

That being said try something like

SELECT t1.name, t1.totm, t1.csa, t2.cell_n, t2.place
FROM tya019 t1 JOIN tya0191 t2
  ON t1.rno = t2.rno

Upvotes: 5

Related Questions