If you execute the SQL above you will always get 0 results.

I think that what cake does by default (using IN) is exactly the thing you 
want, based on what you described (your hesitance on using UNION queries to 
get all results)

On Monday, March 9, 2015 at 8:54:09 PM UTC+1, michel martins wrote:
>
> I need for all products that have tag_id = array item
>
> SELECT * FROM produtos AS Produtos LEFT JOIN tags_produtos as TagsProdutos 
> ON Produtos.id = TagsProdutos.produto_id  WHERE TagsProdutos.tag_id = 730 
> AND TagsProdutos.tag_id = 731 AND TagsProdutos.tag_id = 735
>
> I have doubts whether I do the sql above or use UNION between multiple 
> queries.
>
> Table PRODUTOS
> ID - PRODUTO
>
> Table TAGS_PRODUTOS
> ID - PRODUTO_ID - TAG_ID 
>
> Table TAGS
> ID - NAME
>
> $tags = array('0'=>'730', '1'=>'731', '2'=>'735')
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to