I have business table and there is also a sf_tagging table to save the tags for that business. The query used for selecting the businesses is given below. In this sf_tagging table is left joined with business table. Since there will be different results for different tags of same business, I have grouped the results by business id(which is same as taggable_id in sf_tagging table). But the problem is that from amongst the businesses which have no tags, only one is selected since the taggable_id for all of them is null. Is there any way in which the query can be modified so that the results will not be grouped for cases in which there are no tags, and grouped in all other cases?
select business.ID,business.NAME,business.CATCH_LINE,business.ADDRE SS_ID,sf_tagging.TAGGABLE_ID from business join member on business.MEMBER_ID=member.ID left join sf_tagging on (business.ID=sf_tagging.TAGGABLE_ID and sf_tagging.TAGGABLE_MODEL='Business') left join sf_tag on (sf_tagging.TAG_ID=sf_tag.ID) where (business.NAME LIKE '%testing%' or sf_tag.TRIPLE_KEY= 'testing') and member.STATUS='active' and business.STATUS= 'active' group by sf_tagging.TAGGABLE_ID Thx in advance Dijil --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony users" 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/symfony-users?hl=en -~----------~----~----~----~------~----~------~--~---
