Monday, March 9, 2015

Re: Condition with AND and ARRAY

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+unsubscribe@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.

No comments: