当我拉下MySQL代码时:
SELECT distinct *
FROM product_size AS ps
INNER JOIN product_type AS pt ON ps.product_id = pt.product_id
WHERE product_type = 'Business Card'
;
提取以下图片:
我要做的是确保当我们从我们的网站上提取它时,它只在我们的页面上拉出一个大小的实例。
所以基本上,当我们在我们的网站上进行选择时,我希望它能够拉大小。
当我在我们的网站上提取它时,会出现以下内容:
答案 0 :(得分:1)
我假设您的product_id是唯一的,因此请使用product_id而不是所有记录。
SELECT distinct ps.product_id, ps.*
FROM product_size AS ps
INNER JOIN product_type AS pt ON ps.product_id = pt.product_id
WHERE product_type = 'Business Card' ;
答案 1 :(得分:0)
你可以像这样轻松删除不必要的物品
SELECT DISTINCT size, produce_type, p_dimension
FROM
(SELECT distinct *
FROM product_size AS ps
INNER JOIN product_type AS pt ON ps.product_id = pt.product_id
WHERE product_type = 'Business Card')
或
SELECT DISTINCT rs.size, rs.produce_type, rs.p_dimension
FROM
(SELECT distinct *
FROM product_size AS ps
INNER JOIN product_type AS pt ON ps.product_id = pt.product_id
WHERE product_type = 'Business Card') rs