简体   繁体   中英

PGSQL Error Code 42703 column does not exist

I have a database in postgreSQL. I want to read some data from there, but I get an error ( column anganridref does not exist ) when I execute my command.

Here is my NpgsqlCommand:

cmd.CommandText = "select * from angebot,angebotstatus,anrede where anrid=anganridref and anstaid=anganstaidref";

and my 3 tables

http://img4.fotos-hochladen.net/uploads/unbenanntg4059ucm6j.png

the names of my columns are rights. So I don't understand why that error comes. Someone can explain me why it does crash? Its not the problem of large and lowercase.

You are not prefixing your column names in the where clause:

select * 
from angebot,
     angebotstatus,
     anrede 
where anrid = anganridref   <-- missing tablenames for the columns
  and anstaid = anganstaidre

It's also recommended to use an explicit JOIN instead of the old SQL 89 implicit join syntax:

select * 
from angebot 
   join angebotstatus on angebot.aaaa = angebotstatus.bbbb
   join anrede on angebot.aaaa = anrede.bbbb

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM