How to frame a MySql query which return result which has all the values in an array? -


my mysql query looks

select * node nd left join term_node trm_nd on trm_nd.nid = nd.nid nd.title = 'gadget - definition'  , nd.type = 'help_system'  , trm_nd.tid in (434, 456, 25, 293) 

which returns result

------------------------------------------------------- nid     title                   type           tid ------------------------------------------------------- 26986   gadget - definition     help_system     25 26986   gadget - definition     help_system     293 52421   gadget - definition     help_system     25 52421   gadget - definition     help_system     293 73061   gadget - definition     help_system     25 73061   gadget - definition     help_system     293 86071   gadget - definition     help_system     25 86071   gadget - definition     help_system     293 98596   gadget - definition     help_system     25 98596   gadget - definition     help_system     293 98596   gadget - definition     help_system     434 98596   gadget - definition     help_system     456 

but need result below one, need return values has nid associated array values (434, 456, 25, 293) in tid column

------------------------------------------------------- nid     title                   type           tid ------------------------------------------------------- 98596   gadget - definition     help_system     25 98596   gadget - definition     help_system     293 98596   gadget - definition     help_system     434 98596   gadget - definition     help_system     456 

use group by in existing query , make sub query, this:

select * node n1 join (   select nid node nd   left join term_node trm_nd on trm_nd.nid = nd.nid   nd.title = 'gadget - definition'    , nd.type = 'help_system'    , trm_nd.tid in (434, 456, 25, 293)   group nid   having (count(distinct tid)) = 4 ) t1 on n1.nid = t1.nid 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -