Re: SQL "OR" Problem - Mailing list pgsql-novice

From Stephan Szabo
Subject Re: SQL "OR" Problem
Date
Msg-id 20050826131954.D29460@megazone.bigpanda.com
Whole thread Raw
In response to SQL "OR" Problem  (<operationsengineer1@yahoo.com>)
List pgsql-novice
On Fri, 26 Aug 2005 operationsengineer1@yahoo.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')


pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: SQL "OR" Problem
Next
From: Bruno Wolff III
Date:
Subject: Re: SQL safe input?