跨两个表的SQL显示重复记录

查理

使用此SQL:

SELECT p.* 
FROM shop_products p, shop_product_attributes c 
WHERE c.type = 'category' AND p.sequence = c.value AND c.value = '1' 

它两次显示相同的记录。

应该示出从排shop_products where shop_products.sequence是在shop_product_attributes.product_seqshop_product_attributes.value'1'

陈杜尔
SELECT s.* 
FROM shop_products s
where s.sequence 
in(select distinct product_seq from shop_product_attributes where type = 'category' and value=1)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章