这里有个问题

select stockrequest.clientnum, requestlist.productnum,requestlist.qtyrequest
from stockrequest, requestlist
where stockrequest.requestnum = requestlist.requestnum

此查询将导致
client num   productnum    qty
1            123            4
2            345            5
3            456            7


select client.clientname, stockrequest.clientnum
from client , stockrequest
where stockrequest.clientnum = client.clientnum

clientname   clientnum
yd              1
myer            2
nike            3

我需要一个子查询,在第一个查询中将clientnum替换为client name

最佳答案

进行三向连接:

SELECT c.clientname, rl.productnum, rl.qty
FROM stockrequest AS sr
JOIN client AS c ON c.clientnum = sr.clientnum
JOIN requestlist AS rl ON rl.requestnum = sr.requestnum

关于mysql - 如何解决Mysql子查询,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24053964/

10-10 06:36