Re: SQL "OR" Problem

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: operationsengineer1(at)yahoo(dot)com
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: SQL "OR" Problem
Date: 2005-08-26 20:24:50
Message-ID: 20050826131954.D29460@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


On Fri, 26 Aug 2005 operationsengineer1(at)yahoo(dot)com wrote:

> hi all,
>
> i'm trying to populate a list box with the names of
> employees linked to certain positions (each name
> listed once)...
>
> SELECT DISTINCT t_emp.emp_id, t_emp.first_name || ' '
> || t_emp.last_name, t_pos.pos
>
> FROM t_inspect, t_emp, t_pos
> WHERE t_emp.pos_id = t_pos.pos_id
> AND t_inspect.inspect_emp_id = t_emp.emp_id
> AND t_pos.pos = 'Assembler'
> OR t_pos.pos = 'Quality Inspector'
> OR t_pos.pos = 'Test Technician'

Have you tried it with parens? I'm guessing you probably wanted something
more like:

WHERE t_emp.pos_id = t_pos.pos_id
AND t_inspect.inspect_emp_id = t_emp.emp_id
AND (t_pos.pos = 'Assembler'
OR t_pos.pos = 'Quality Inspector'
OR t_pos.pos = 'Test Technician')

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2005-08-26 20:27:47 Re: SQL "OR" Problem
Previous Message Frank Bax 2005-08-26 20:18:20 Re: SQL "OR" Problem