RE: ambiguous
От | Tamsin |
---|---|
Тема | RE: ambiguous |
Дата | |
Msg-id | NEBBKHBOBMJCHDMGKCNJOEMDCKAA.tg_mail@bryncadfan.co.uk обсуждение исходный текст |
Ответ на | ambiguous (si <s@remail.net>) |
Список | pgsql-novice |
You need to qualify which dept_id you are refering to in your where clause: select * from department, employee where department.dept_no = '1'; Also, unless you join the two tables in your where clause you'll get a cartesian join, so you might want to do: select * from department, employee where department.dept_no = '1' and department.dept_no = employee.dept_no; You can also use aliases for your tablenames to save typing: select * from department d, employee e where d.dept_no = '1' and d.dept_no = e.dept_no; Hope this helps, Tamsin > -----Original Message----- > From: pgsql-novice-owner@postgresql.org > [mailto:pgsql-novice-owner@postgresql.org]On Behalf Of si > Sent: 07 March 2001 15:33 > To: pgsql-novice@postgresql.org > Subject: [NOVICE] ambiguous > > > If I assign the same name to 2 columns in 2 different tables: > > +--------------------------------------+ > | DEPARTMENT | > +----------+----------------+----------+ > | LOCATION | DESCRIPTION | DEPT_NO | > +----------+----------------+----------+ > | Bedrock | Administration | 1 | > +----------+----------------+----------+ > > +--------------------------------+ > | EMPLOYEE | > +---------+------------+---------+ > | EMPL_ID | NAME_LAST | DEPT_NO | > +---------+------------+---------+ > | 1 | Slate | 1 | > +---------+------------+---------+ > > select * from DEPARTMENT, Employee where dept_no = '1'; > > PG throws up: > ERROR: Column 'dept_no' is ambiguous > > Is this not allowed? or is my sql understanding wrong? > > > _____________________________________________________________ > Pick up your email anywhere in the world ---> http://www.remail.net > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly >
В списке pgsql-novice по дате отправления: