Viewer code error - x AND y OR y

3 posts by 2 authors in: Forums > CMS Builder
Last Post: October 28, 2009   (RSS)

Hi guys,

I have a bunch of stores on a page pulled from store locations table. I want to show only stores that are from region 'Queensland" AND are a store_type of either a "ABC" store or an "other" store.

My viewer code is this:

list($store_locationsqldRecords, $store_locationsqldMetaData) = getRecords(array(
'tableName' => 'store_locations',
'loadUploads' => '0',
'where' => ' region LIKE "%Queensland%" AND store_type LIKE "%ABC%" OR store_type LIKE "%Other%" ',

));


But it keeps showing stores from other states. I presume it is because for some reason it is only paying attention to the second part of the condition I have set. What's wrong with my syntax?

Thanks in advance!

Re: [benedict] Viewer code error - x AND y OR y

By Dave - October 28, 2009

Hi benedict,

You can add brackets to more explicitly specify your conditions. Try this:

'where' => ' region LIKE "%Queensland%" AND (store_type LIKE "%ABC%" OR store_type LIKE "%Other%") ',

Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com