我有一个SQL服务器中存储MINIMUM_AMOUNT,MAXIMUM_AMOUNT和CURRENCY_ID的表。现在我想构建一个SQL查询,它将检查要插入的新值是否已存在于表中。例如:我的表是有如下Tricky如果存在SQL查询需要检查重叠的值
RANGE_ID MINIMUM_AMOUNT MAXIMUM_AMOUNT CURRENCY_ID
------------------------------------------------------------
1 3000 9000 3
2 12000 17000 3
现在,当用户插入一个新的记录,它不应该已经获得的值之间是2条
即:用户不应该能够进入这些值对
1) Min Amount : 4000 , Max Amount : 5000 ,Currency Id : 3
because this range already lies in the first record (RANGE_ID 1)
2) Min Amount : 8000 , Max Amount : 10000,Currency d : 3
because the minimum amount is already present in the range specified in first record (3000-9000)
3) Min Amount : 8000, Max Amount : 15000 , currency Id=3
because the minimum amount is already present in one range and the maximum amount is also present in another range
4) Min Amount : 2500 , Max Amount : 11000 ,Currency Id=3
because the this range overlaps with the data in first record
用户应该能够使用不同的货币ID输入上述范围。
我在寻找一个If Exists查询来检查这个。
这不处理的重叠检查重叠 – Shyju 2009-12-11 06:54:37