首先我會做你這樣的查詢
SELECT p.name, s.height, s.width, ps.price
FROM product_sizes as ps, product as p, sizes as s
WHERE ps.sizeid = s.sizeid
AND p.productid = ps.productid
AND p.productid=1
比你只需要計算它在選擇 嘗試一些像,其未經測試,我真的不知道這是否工作,但它應該...
SELECT p.name, s.height, s.width, (((ps.price/100)*x)+ps.price) as newPrice
FROM product_sizes as ps, product as p, sizes as s
WHERE ps.sizeid = s.sizeid
AND p.productid = ps.productid
AND p.productid=1
當然,你必須把一些還有其中X爲:)
這有什麼行??? ....(源)
SELECT product.name sizes.height, sizes.width, product_sizes.price
-------------------^ there is a comma missing
FROM product_sizes as s
JOIN sizes ON s.sizeid = sizes.sizeid, product
--------------------------------------------^ what is this ?
JOIN product_sizes on product.productid = product_sizes.productid
WHERE product.productid=1
這是一個真正的查詢嗎?語法看起來不正確。 – dasblinkenlight
其實它是一個真正的查詢 – KEVIN
我還是不明白這個問題^^你想在你的結果中有一個計算價格?!?!? – Dwza