下面的SQL语句怎么写啊,在线等,只有26分了!感谢!

zhaoxueli_fj 2004-04-07 09:47:29
界定电话号码段:
起始段(startpos) 终止段(stoppos) 所属区
3500000 5500000 A
5600000 7500000 B
8000000 8800000 C


往该表插记录,一个form上有两个edit输入框
现在要在insert into前检查输入框内的值是否有存在于界
定范围内,不存在则插入,存在则提示已存在
如:2000000 3000000 这是没问题的
5400000 5700000 不行,这个段的部份(从5600000开始已被界定)
8500000 9000000 不行,8500000到8800000已被界定

怎么判断啊?
...全文
24 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zjcxc 元老 2004-04-07
  • 打赏
  • 举报
回复
declare @edit1 int,@edit2 int
select @edit1=5400000
,@edit2=5700000

if exists(select 1 from 表 where @edit1 between startpos and stoppos
or @edit2 between startpos and stoppos)
print '已经存在'
else
insert ...
zhaoxueli_fj 2004-04-07
  • 打赏
  • 举报
回复
能否详细点啊,我马上要用,谢谢
zhaoxueli_fj 2004-04-07
  • 打赏
  • 举报
回复
说一下思路啊
azsoft 2004-04-07
  • 打赏
  • 举报
回复
if exists (select 1 from table where 字段<=startpos and 字段>=stoppos )
insert into .....
zheninchangjiang 2004-04-07
  • 打赏
  • 举报
回复
select 1 from tablename where (startpos>value1 and stoppos<value1) or (startpos>value2 and stoppos<value2)
ghostzxp 2004-04-07
  • 打赏
  • 举报
回复
用程序处理不好吗?
zhaoxueli_fj 2004-04-07
  • 打赏
  • 举报
回复
最上面的
起始段(startpos) 终止段(stoppos) 所属区
是表的三个字段,现在要插入数据,插入前检查数据合法性
我怕没说清楚

34,591

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧