Ashley Sheridan wrote:
On Mon, 2009-12-07 at 11:52 +0100, Merlin Morgenstern wrote:
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?
You have described the problem very well. This is exactly where I can
not find a solution.
the page number translates to the following: 1= first page 2= following
pages 3= all pages
This are the options a user has while booking a product on my site. Now
if ther is a new
client that wants to book all pages, I need to query the table to find
out if the spot is available.
The spot would be full if page 1 has more results then 3 , OR all
following pages have more then 3 results. So to find out if "all pages"
option would be available I need to query the db to retrieve all
results, that are (page = 3) OR (page = 1 XOR 2)
Am I wrong?