WHERE CASE/IF

3 posts by 2 authors in: Forums > CMS Builder
Last Post: June 15, 2010   (RSS)

Re: [rjbathgate] WHERE CASE/IF

By Jason - June 15, 2010

Hi,

There is actually an easier way to create this.
Since we always want vehicle_category=2, we can use that in either case. Apart from that, we want to select any record that have either been sold in the past month, or not sold at all.

Try this query:

'where' => "vehicle_category='2' AND (sold_date > (NOW() - INTERVAL 1 MONTH) OR sold_date=0)"

This should return the records you're looking for.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] WHERE CASE/IF

By rjbathgate - June 15, 2010

Perfect, I like simple solutions, thanks...

Didn't even consider that as didn't think I'd be able to specific OR is blank...

:)

Cheers Jason