谁能告诉我如何做到这一点......
Table 1 Table 2
Cat_ID Cat_Name Term_ID Term_Name
1 ab 1986 January 2013
2 cd 1987 February 2013
3 ef 1988 March 2013
4 gh
我希望输出为:
Table 3
Term_ID Term_Name CAT_ID CAT_Name
1986 January 2013 1 ab
1986 January 2013 2 cd
1986 January 2013 3 ef
1986 January 2013 4 gh
1987 February 2013 1 ab
1987 February 2013 2 cd
1987 February 2013 3 ef
1987 February 2013 4 gh
1988 March 2013 1 ab
1988 March 2013 2 cd
1988 March 2013 3 ef
1988 March 2013 4 gh
我必须把它写成一个 SQL 查询。