0

This is probably very easy and just I'm being thick - I'm trying to stop reserved items from being picked up in the records but only if the stock is greater than 0, I can't work out how to do an unless

"....WHERE blah blah AND (reserved = 0 OR reserved < ".(time()-1200).")"

So the column I'm looking at is called the "stock" column and if that value is 0 then I DO want to display the result

So I thought I could do

if(stock<>0,reserved = 0 OR reserved < ".(time()-1200.")

But that errors...

2
  • What defines a "reserved item"? Commented Apr 16, 2012 at 15:45
  • it's an item that has been timestamped by another user as being in their basket for purchase, I give them 20 minutes to buy it in the meantime I don't want to display those in the shop Commented Apr 17, 2012 at 8:04

2 Answers 2

1

you can't do assignments like that in an if() clause. The format is

if (condition, true_value, false_value)

Possibly something like this will do:

if (stock <> 0, 0, time()-1200) AS reserved
Sign up to request clarification or add additional context in comments.

1 Comment

doesn't that go in the SELECT part though? I need it to be in the WHERE clause
0

I may have misunderstood but wont:

"WHERE blah blah AND (stock = 0 OR reserved = 0 OR reserved < ".(time()-1200).")))"

do what you need?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.