How can the same field have multiple values?
-it can be = '3'
-it can be= '4''

Otherwise maybe your are just concatenating multiple variables into
one, e.g.;
-it can be='3,4'
which probably should be evaluated for best practices..

You would not use IN in such a case.

If the are always ordered numerically you might use;
AND options.option like '%3,4%'
(assuming there are higher or lower values (2,..,5))

If they are not always order and could be 4,3 or 4,5,3 then you might
try;
AND options.option like '%3%' AND options.option like '%4%



On Dec 22, 11:21 am, dev <[email protected]> wrote:
> i'm building custom SQl query and need a little help.
>
> query:
> select distinct adverts.id, adverts.code from adverts left join images
> on (images.advert_id = adverts.id) left join options on
> (options.advert_id = adverts.id) where (SELECT count(1) FROM images
> WHERE adverts.id = images.advert_id) > 0 AND options.option IN (3, 4);
>
> but i want to get all Advert records, where options.option has all
> these values (3,4). When i'm using IN(), these values are with OR
> operator, how to set AND?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to