Re: Complex query need help with OR condition.

Поиск
Список
Период
Сортировка
От Ken Tozier
Тема Re: Complex query need help with OR condition.
Дата
Msg-id BE89E67E-2640-11D9-87A4-003065F300E2@comcast.net
обсуждение исходный текст
Ответ на Re: Complex query need help with OR condition.  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Oct 25, 2004, at 12:35 AM, Tom Lane wrote:

> Ken Tozier <kentozier@comcast.net> writes:
>> When I add the OR clause things go haywire:
>
>> SELECT a.paginator, a.doc_name, (b.time - pm_events.time) as
>> elapsed_time FROM pm_events as a, pm_events as b
>>     WHERE a.event_code='pmcd'
>>     OR a.event_code='pmop'
>>     AND b.event_code='pmcl'
>>     AND a.doc_name=b.doc_name
>>     AND a.paginator=b.paginator
>>     AND a.time < b.time
>
> I think you need some parentheses, or at least a bit of thought about
> what the OR is binding to.

The table stores "file open", "file create" and "file close" events
(pmop, pmcd, pmcl) What I'm trying to do is bind "open" and "create"
events to the next sequential close event for each document a
particular paginator works on. I also tried parentheses after the where
clause like so:

WHERE (a.event_code='pmcd' OR a.event_code='pmop')

But it only seems to recognize the first comparison ignoring whatever
comes after the OR


В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Complex query need help with OR condition.
Следующее
От: Jeff Davis
Дата:
Сообщение: Re: pqAdmin3