mssql问题
现在有两张表Table1、Table2 table1 ID Uid1 Uid2 1 1 2 table2 Uid Name 1 a 2 b 怎么能查询出这样的结果 Uid1 Uid2 Name1(Uid1对应的Name) Name2(Uid2对应的Name) 1 2 a b
现在有两张表Table1、Table2 table1 ID Uid1 Uid2 1 1 2 table2 Uid Name 1 a 2 b 怎么能查询出这样的结果 Uid1 Uid2 Name1(Uid1对应的Name) Name2(Uid2对应的Name) 1 2 a b
答案:SELECT A.UID1,A.UID2,B.NAME NAME1,C.NAME NAME2 FROM TABLE1 A LEFT JOIN TABLE2 B ON B.UID=A.UID1
LEFT JOIN TABLE2 C ON C.UID=A.UID2