select id from u where tKey in (select id from t where tlkey = 1117)
and u.ckey = 15
union all
select * from u where tKey in (select id from t where tlkey = 1116)
and u.ckey = 15
union all
select * from u where tKey in (select id from t where tlkey = 16)
and u.ckey = 15
union all
select * from u where tKey in (select id from t where tlkey = 1118)
and u.ckey = 15
union all
select * from u where tKey in (select id from t where tlkey = 1119)
and u.ckey = 15
表U: -需要选择查询转换与功能的SQL
id tKey
16 1047
20 34
35 34
1116 1048
1117 1048
1118 1047
1119 1049
表t: -
id tlkey
34 16
1047 1116
1048 1117
1049 1118
预期输出: -
id
1116
1117
16
1118
20
35
1119
打招呼
我想把这个查询转换为SQL与函数我不明白我该怎么做。第一个查询输出是(1117,1116) 第二个查询输出是(16,1118)意思是我们需要用第一个查询输出到第二个然后去最后一个级别我不知道最后一个是什么 我该怎么做请帮我
你怎么“想把这个查询转换为带有函数的sql”?说明! – jarlh
,因为它是递归查询的手段。第一个查询输出为其他查询输入。而不是查询输入的其他查询的输出 –
添加一些示例表格数据和预期结果 - 以及格式化文本。 – jarlh