我有一個很長的查詢,我通過使用連接將其縮短出來,而生成的查詢如下,但它仍然有子查詢。如何轉換這個子查詢加入翻譯sql子查詢加入
SELECT
pav.post_id as Id, img.path as Path, attr.name as Name, pc.title as Category, pav.value_text as Valuess, post.created_on as createdOn
FROM
postings post inner join post_attributes_values pav on post.post_id = pav.post_id
left outer join images img on post.post_id = img.post_id and img.sequence='1'
inner join attributes attr on pav.attr_id = attr.attr_id
inner join categories_parent_categories pc on attr.cat_id = pc.category_id
where
pav.post_id in (select distinct post_id from post_attributes_values where value_text = 'SFX')
是不同的必要嗎?您是否搜索具有值'SFX'的特定屬性或任何屬性會執行? – 2012-08-03 10:52:16
@NikolaMarkovinović:桌子的設計就像是有必要的。 – 2012-08-03 11:02:43
獨特不應該在子查詢中不需要,因爲您只是在檢查.... – 2012-08-03 11:37:24