我有2张桌子。 (table1& table2)
表1家长:
ID | Description
11058744 | A
11058745 | A
11058746 | A
表2儿童:
ID | REFCODE
11058745 | 11058744
11058744 | 11058745
11058746 | 11058744
11058744 | 11058746
我希望结果如下所示:
ID | REFCODE
11058744 | 11058744
11058745 | 11058744
11058746 | 11058744
答案 0 :(得分:0)
以下查询将生成您请求的结果:
WITH A AS (SELECT DISTINCT ID AS ID FROM TABLE1),
B AS (SELECT MIN(REFCODE) AS REFCODE FROM TABLE2)
SELECT A.ID, B.REFCODE
FROM A
CROSS JOIN B;
分享并享受。