私はSQLクエリを持っています:
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%')
)
私の問題は、WHERE 句内のクエリの部分を単純化する必要があることです (contactmeta テーブルなどと別の結合を行うことはできません)。これは、静的な SQL に対して WHERE 句が動的に作成されるためです。
t.name 条件を除いて、両方の where 条件がほぼ同じであることがわかります。
御時間ありがとうございます
SK