On Mon, 2009-12-07 at 11:52 +0100, Merlin Morgenstern wrote:
> Hello everybody,
> I am having trouble finding a logic for following problem:
> Should be true if:
> page = 1 OR page = 3, but it should also be true if page = 2 OR page = 3
> The result should never contain 1 AND 2 in the same time.
> This obviously does not work:
> (page = 1 OR page = 3) OR (page = 2 OR page = 3)
> This also does not work:
> (page = 1 OR page = 3 AND page != 2) OR (page = 2 OR page = 3 AND page != 1)
> Has somebody an idea how to solve this?
> Thank you in advance for any help!
I thought this might work:
(page = 3) OR (page = 1 XOR 2)
But having given it more thought, I'm not so sure. I assume from your
example that this is MySQL code and not PHP. Having said that, how can a
field of one row have more than one value? Surely `page` is either 1, 2
or 3, not two of them at once. How do you want your results pulled?
Assuming you have rows containing all three values, how do you decide
which of the pair of results you want?