我想获取一个id列表,该列表在第二个表的范围内,其范围为id。
第一张表
Table (ID)
1
2
...
73
第二张表:
Table (Ranges)
id_lower || id_upper
50 55
48 53
...
68 73
结果表:
Result Table (id)
48
49
50
51
...
提前致谢....
FreshPrinceOfSO要求的更新:
SELECT DISTINCT M.id_modelo
FROM modelo M
WHERE M.id_modelo BETWEEN
(
SELECT G.id_modelo_inicial
FROM general G
WHERE G.id_modelo_inicial = M.id_modelo
)
AND
(
SELECT G.id_modelo_final
FROM general G
WHERE G.id_modelo_final = M.id_modelo
);
答案 0 :(得分:1)
SELECT DISTINCT TableA.ID
FROM
TableA INNER JOIN Ranges
ON TableA.ID BETWEEN Ranges.id_lower AND Ranges.id_upper
答案 1 :(得分:0)
从ID中选择ID,其中ID.id> = Ranges.id_lower和ID.id< = Ranges.id_upper
我假设表ID中列的名称是'id'。