-1

我有以下情况:

两张表,它们的结构是这样的:

[机器](父表):

machine_id (PK) | machine_name | desc

[machine_in_out](子表):

id (PK) | machine_in_id | machine_out_id

现在我想通过父表获取machine_in_id,的名称。machine_out_id

如何使这个加入?!

4

1 回答 1

3

尝试这个...

Select  mio.ID, 
        m1.machine_name, 
        m2.machine_name
From    [machine_in_out] mio
Join    [machine] m1
        On  mio.machine_in_ID = m1.machineID
Join    [machine] m2
        On  mio.machine_out_ID = m2.machineID
于 2013-05-08T14:17:52.510 回答