我有兩個表:使用Select語句,其中X IN(SELECT ...)
[ product_to_category
---------------------
product_id
category_id
[ category
---------------------
category_id
parent_id
我需要把所有的product_id與 '39' 的category.parent_id。這裏就是我想要的,但如果至少有幾百它返回空:
SELECT
product_id
FROM
product_to_category
WHERE
category_id IN (
SELECT parent_id FROM category WHERE parent_id = '39'
)
是什麼,我想在這裏做可能嗎?
參考:http://stackoverflow.com/questions/1772609/procedurally-transform-subquery-into-join – 2009-12-04 20:43:33