Re: Using AND in query

From: John R Pierce <pierce(at)hogranch(dot)com>
To: Thomas Kellerer <spam_eater(at)gmx(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Using AND in query
Date: 2010-08-08 08:55:19
Message-ID: 4C5E70F7.3010102@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


>
> The condition
>
> and table.item = 'laptop' and table.item = 'Desktop'
>
> says: I want all rows where the column item has the value 'Laptop' and
> *at the same time* has the value 'Desktop'
> Which clearly cannot be the case (a column can only have a single value)
>
> So you need to join all "Laptop" rows to all "Desktop" rows to get
> what you want.

why not use OR ?

... AND (table.item = 'laptop' OR table.item='Desktop') ...

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Kellerer 2010-08-08 09:01:21 Re: Using AND in query
Previous Message Alban Hertroys 2010-08-08 08:46:18 Re: Using AND in query