1

假设我有 2 张桌子:

USER(uid, uname);
ITEM(iid, description);
TRANSACTION(buyer, seller, item);

transaction.buyertransaction.seller参考资料user.uidtransaction.item参考item.iid

如何查询交易的买卖双方姓名?

4

1 回答 1

3

你需要两个连接:

select t.*, b.uname as buyerName, s.uname as sellerName
from transaction t join
     user b
     on t.buyer = b.uid join
     user s
     on t.seller = s.uid
于 2013-02-19T22:46:35.603 回答