Buy Now
Sign in

search with OR and not AND

webcrea , March 23 2017
Answered
webcrea
Hi,
cc6 build search with AND when several fields are indicate in "Searchable fields". In this case nothing appears in result,
Is it possible to build the query with OR ?
Thanks
Christophe
http://www.webcrea.fr
admin
Hi Chris,

Yes, but you will need to add the fields in the "where conditions" instead and remove them from the "searchable fields".


Model.field1/LIKE:%{data:keywords}%
OR
Model.field2/LIKE:%{data:keywords}%
OR
Model.field3/LIKE:%{data:keywords}%


Best regards,
Max
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
webcrea
Super
Thanks a lot
Christophe
http://www.webcrea.fr
NickOg
HI
Further to this - how can I modify the query so:
(​
​Model.firstname/LIKE:%{data:firstname}%​
​AND​
​Model.lastname/LIKE:%{data:lastname}%​
​)​
​OR​
​Model.address/LIKE:%{data:address}%

​​
I can't seem to force those enclosing (). I have tried 'escaping' them /( and /) with no success. Do I need to resort to PHP?????
Regards
Nick
webcrea
Hi,
do you try this ?
(
Model.firstname/LIKE:%{data:firstname}%
Model.lastname/LIKE:%{data:lastname}%
)
OR
Model.address/LIKE:%{data:address}%
Christophe
http://www.webcrea.fr
healyhatman
(​
​Model.firstname/LIKE:%{data:firstname}%​
​AND​
​Model.lastname/LIKE:%{data:lastname}%​
​)/-​
​OR​
​Model.address/LIKE:%{data:address}%/-
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
NickOg
Thanks Gents. I can get Christophe's solution to work just fine but not that from HealyHatman.
Pretty sure that I have the syntax copied correctly:-
(​
​mdlCheckName.lastname/LIKE:{data:lastname}%​
​AND​
​mdlCheckName.firstname/LIKE:{data:firstname}%​
​)/-​
​OR​
​mdlCheckName.street/LIKE:{data:address}%/-
I am just checking that some more.
Regards
Nick