我有一个很长的查询,我通过使用连接将其缩短出来,而生成的查询如下,但它仍然有子查询。如何转换这个子查询加入翻译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