Skip site navigation (1) Skip section navigation (2)

Re: SQL "OR" Problem

From: <operationsengineer1(at)yahoo(dot)com>
To: Steve Crawford <scrawford(at)pinpointresearch(dot)com>,pgsql-novice(at)postgresql(dot)org
Subject: Re: SQL "OR" Problem
Date: 2005-08-26 21:32:07
Message-ID: (view raw or whole thread)
Lists: pgsql-novice
first off, thanks to everyone who posted their
responses.  rather than flood the list with multiple
response, this one will address everyone (see below
for reason why).

> 1) Is the t_inspect in there for a reason? I don't
> see it referenced 
> in your output or elsewhere in the where clause.
> Perhaps you are 
> looking only for inspectors?

great question.  i was working on another query and i
must have gotten t_inspect stuck in my head enough
that i couldn't get it out.

> If so, an alternate
> method of writing 
> this where the intent is easier to grok is:
> AND exists (select 1 from t_inspect where
> inspect_emp_id = 
> t.emp.emp_id)

with the help of everyone here...  i was able to get
this to work...

SELECT DISTINCT t_emp.emp_id, t_emp.first_name || ' '
|| t_emp.last_name, t_pos.pos
FROM t_emp, t_pos
WHERE t_emp.pos_id = t_pos.pos_id
AND (t_pos.pos = 'Assembler' 
OR t_pos.pos = 'Quality Inspector'
OR t_pos.pos = 'Test Technician')

leaving t_inspect in the query yielded an abbreviated
resultset so removing it (and its associated portion
of the where clause) was necessary to get accurate

> 2) If an employee has several positions

in my current set up, this isn't possible.  certain
people are responsible for certain functions and there
is very little overlap.  i might decide to revisit
this constraint, though.

> or alternately
> ...t_pos.pos IN ('Assembler', 'Quality Inspector',
> 'Test Technician')

Making this change in my now working query yields the
exact same result - success.

> > 2. if an employee is a Qaulity Inspector...
> This line gave my best chuckle of the day :).

i have to admit, that *IS* funny...  but the day isn't
over yet and i may not be finished posting!  -lol-

> Thanks.
> Cheers,
> Steve

no, no.  thank you and everyone else who helped me
with this problem.

Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

In response to


pgsql-novice by date

Next:From: operationsengineer1Date: 2005-08-26 21:46:45
Subject: Re: SQL "OR" Problem - Small Update
Previous:From: Philip HallstromDate: 2005-08-26 20:57:26
Subject: Re: SQL safe input?

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group