WHERE equivalent of "fieldname_keyword" search
5 posts by 2 authors in: Forums > CMS Builder
Last Post: May 22, 2018 (RSS)
By gversion - May 17, 2018
Hello,
Can someone please help me with the syntax for a WHERE clause that will return listings in an equivalent way to:
fieldname_keyword
Contains keyword
Field value must contain keyword (case-insensitive)
The above is taken from: https://www.interactivetools.com/docs/cmsbuilder/viewer_search.html
The problem I am running into is that CMSB deprecates using the % sign in a WHERE clause (e.g. WHERE product LIKE %television%)
Any help would be greatly appreciated.
Thank you,
Greg
By leo - May 18, 2018
Hi Greg,
Did you put quotes for the like statement? For example: where product like "%television%".
interactivetools.com
By gversion - May 19, 2018
Hi Leo,
Thank you for the message. Does the below now look correct?
// load records from 'listings'
list($listingsRecords, $listingsMetaData) = getRecords(array(
'tableName' => 'listings',
'perPage' => '10',
'loadUploads' => true,
'allowSearch' => false,
'where' => product like "%television%"
));
Also, can you please tell me how to write a WHERE clause that works in the same way as the "fieldname_prefix" search type?
Thank you very much for the help!
Regards,
Greg
By leo - May 22, 2018
Hi Greg,
To make it the same as prefix, the where statement should be 'product like "television%"'.
Thanks,
interactivetools.com