http://dev.mysql.com/doc/refman/5.0/en/subqueries.html
SELECT * FROM t1 WHERE column1 = (SELECT column1 FROM t2);
DELETE FROM t1
WHERE s11 > ANY
(SELECT COUNT(*) /* no hint */ FROM t2
WHERE NOT EXISTS
(SELECT * FROM t3
WHERE ROW(5*t2.s1,77)=
(SELECT 50,11*s1 FROM t4 UNION SELECT 50,77 FROM
(SELECT * FROM t5) AS t5)));
Subquery Syntax
Re: 最後進貨單價
select a.prod_id,a.supply_id,a.stock_order_id,a.price from stock_order_b a join (SELECT prod_id, MAX(stock_order_id) AS aa FROM stock_order_b GROUP BY prod_id)b where a.prod_id = b.prod_id and a.stock_order_id = b.aa;