Hi!
I have a Sql Query:
select * from contactmeta
WHERE
contactmeta.contact_id in
(
select tob.object_id from tagobject tob, tag t, taggroup tg
where tob.tag_id = t.tag_id
and t.tag_group_id = tg.tag_group_id
and tob.object_type_id = 14
and tg.org_id = contactmeta.group_id
and (t.name like '%campaign%')
)
AND
contactmeta.contact_id in
(
select tob.object_id from tagobject tob, tag t, taggroup tg
where tob.tag_id = t.tag_id
and t.tag_group_id = tg.tag_group_id
and tob.object_type_id = 14
and tg.org_id = contactmeta.group_id
and (t.name like '%bounced%')
)
My problem is that I need to simplify the part of the query inside the WHERE clause (I cannot make another join with the contactmeta table etc.). This is because the WHERE clause is dynamically created on an otherwise static sql.
You can see that both the where condition is almost same except for the t.name condition.
Thanks for your time
SK