select id,(select name from stock where id=a.stockid) as stock,
(select name from stack where id=a.stackid) as stack,
(select name from product where id=a.productid) as product,amount
from A as a
select a.id, b.stock, c.stack, d.product, a.amount
from 主表 as a inner join stock as b on a.stockid = b.id
inner join stack as c on a.stackid = c.id
inner join product d on a.productid = d.id
.
说真的,2个办法都在用,一直不知道到底效率如何,请各位指点。
------解决思路----------------------
建议你小数据量就用上面的,大数据量就用下面的!!!!!
------解决思路----------------------
建议用第二种