0
我有以下SQL-選擇(SQLite的/ MySQL的):減少內部連接
SELECT products.* FROM products
INNER JOIN specifications AS spec1 ON specifications.product_id = product.id
INNER JOIN specifications AS spec2 ON specifications.product_id = product.id
WHERE products.language = "de"
AND products.category = "ABC"
AND (spec1.name = 'Innenabmessungen' AND spec1.value = '182x53')
AND (spec2.name = 'Farbe' AND spec2.value = 'schwarz')
有隻使用一個INNER JOIN
的解決方案?問題是我想用兩個以上的spec-filter來製作SELECT
。這可能嗎?
只要你有合適的索引,連接並沒有那麼糟! – 2011-05-26 09:10:17
恭喜您重新發現[EAV](http://en.wikipedia.org/wiki/Entity-attribute-value_model)帶來的痛苦,當您實際需要查詢屬性時。 – 2011-05-26 09:30:37