【发布时间】:2013-03-26 05:23:00
【问题描述】:
table1 table2
id number start end indicator
11 4 1 5 N
22 6 2 7 N
33 8 5 12 Y
44 10
如果我想要其中的行,加入这些表的最有效方法是什么 table1 对应于 table2 (start,end) 的范围内,其中指标为 Y,用于两个单独的条件;
- table2 中只有一行会有 Y 指示符
- table2 中的一个或多个行将有一个 Y 指示符
即(坏例子)
SELECT * from table1
WHERE table1.number > (SELECT start from table2 WHERE indicator = 'Y')
AND table1.number < (SELECT end from table2 WHERE indicator = 'Y')
【问题讨论】:
标签: sql performance oracle memory-efficient