PHP sql的多个属性

时间:2013-07-23 16:36:30

标签: php mysql

我有以下查询显示我的产品。

SELECT DISTINCT productsmap.id, attributes_product.waarde, 
attributes_product.att_id, productsmap.name, productsmap.category 
AS categoryId, brand.naam AS brand, productsmap.sku, categorie.name AS 
category, productsmap.price, productsmap.shops

FROM productsmap
INNER JOIN categorie ON productsmap.category = categorie.id
INNER JOIN brand ON productsmap.brand = brand.id
INNER JOIN attributes_product ON productsmap.id = attributes_product.pmapid

WHERE productsmap.category
IN ( 2, 3, 4, 5, 6, 7, 8 ) 
AND productsmap.shops >0
AND (
productsmap.price >= 3.94
AND productsmap.price <= 204.99
)
AND productsmap.online =1
LIMIT 0 , 30

它给出了我的裁剪结果:

(id) (waarde) (att_id) (name) (categoryId) (brand) (sku) 
 2     109        1     Name       4        Merk   70000  
 2     2013       2     Name etc etc etc 
 2     123        3     Name etc etc etc 
 3     103        1     Name2  etc etc 
 3     2012       2     Name2
 3     123        3     Name2
 4     110        1     3name
 4     2013       2     3name
 4     102        3     3name

Whit多次使用相同的id和名称,只有不同的att_id和waarde。但我需要添加到我的查询(attributes_product.att_id = 1和waarde = 109)和(attributes_product.att_id = 2和waarde = 2013)

但这是不可能的,因为它是不同的结果。我该如何解决这个问题?或者我可以搜索什么来解决这个问题?

它的属性。产品是att_id和waarde

0 个答案:

没有答案