请教:关于SQL的查询问题 试试:QuerySBCL.SQL.Add('Where substring(系统源槽路,5,5) between ''1'' and ''50'' '); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 QuerySBCL.SQL.Add('select * ');QuerySBCL.SQL.Add('from 设备槽路 ');QuerySBCL.SQL.Add('Where left(系统源槽路,10)>=''1-1-1'' left(系统源槽路,10)<=''1-1-50'' '); 结合top和like进行查询select top 50 * from xxx where fieldx like "1-1-%" 哦,刚才说的还有点问题,substring(系统源槽路,5,5) 你应该改成:substring(系统源槽路,5,length(rtrim(系统源槽路))-5). 因为你取得值可能为2或者更多位。 需要这么麻烦吗,直接选择就可以QuerySBCL.SQL.Add('select * ');QuerySBCL.SQL.Add('from 设备槽路 ');QuerySBCL.SQL.Add('Where 系统源槽路 >= ''1-1-1'' ');QuerySBCL.SQL.Add(' and 系统源槽路 <= ''1-1-50'' ');字符串也可以比较的 QuerySBCL.SQL.Add('select * ');QuerySBCL.SQL.Add('from 设备槽路 ');QuerySBCL.SQL.Add('Where convert(int,substring(系统源槽路,5,2)>=1 and convert(int,substring(系统源槽路,5,2)<=50'); 以上的各位都对,不过请注意所有SQL语句前或后记得加空格 QuerySBCL.SQL.Add('select * from 设备槽路 Where 系统源槽路 >= ''1-1-1'' and 系统源槽路 <= ''1-1-50'' '); QuerySBCL.SQL.Add('select *');QuerySBCL.SQL.Add('from 设备槽路');QuerySBCL.SQL.Add('Where convert(int,substring(系统源槽路,5,5)) between 1 and 50 ');中的convert(int,substring(系统源槽路,5,5))必须为表中的一个字段,否则编译会现你所提到的错误信息. QuerySBCL.SQL.Add('select * ');QuerySBCL.SQL.Add('from 设备槽路 ');QuerySBCL.SQL.Add('Where (系统源槽路 between ''1-1-1''and ''1-1-50'')'); QuerySBCL.SQL.Add('select * ');QuerySBCL.SQL.Add('from 设备槽路 ');QuerySBCL.SQL.Add('Where rtrim(系统源槽路) between ''1-1-1'' and ''1-1-50'''); Indy 10,收邮件时如果判断邮件是否已经收过? 用Shell名字空间扩展技术能不能虚拟出一个盘符出来? 巨简单的送分题,来者有分!100分! 关于C++和DELPHI的数据类型兼容的问题 调用过程出现问题,大家帮我看看 关于image,第一个解决问题者有30分 在Delphi中如何把照片粘贴到控件中 动态连接库中用ADO出错? 我刚学delphi,想编一个mp3和real的播放器。不知如何入手?请帮忙。 我操!在delphi中調用vb的mscomm控件要我注冊(??) 大家简单谈一下,现在学Delphi还有多少前途呢? modem如何继续拨号?向通讯方面的高手求救。
QuerySBCL.SQL.Add('from 设备槽路 ');
QuerySBCL.SQL.Add('Where left(系统源槽路,10)>=''1-1-1'' left(系统源槽路,10)<=''1-1-50'' ');
select top 50 * from xxx where fieldx like "1-1-%"
substring(系统源槽路,5,length(rtrim(系统源槽路))-5).
因为你取得值可能为2或者更多位。
QuerySBCL.SQL.Add('select * ');
QuerySBCL.SQL.Add('from 设备槽路 ');
QuerySBCL.SQL.Add('Where 系统源槽路 >= ''1-1-1'' ');
QuerySBCL.SQL.Add(' and 系统源槽路 <= ''1-1-50'' ');字符串也可以比较的
QuerySBCL.SQL.Add('from 设备槽路 ');
QuerySBCL.SQL.Add('Where convert(int,substring(系统源槽路,5,2)>=1 and convert(int,substring(系统源槽路,5,2)<=50');
QuerySBCL.SQL.Add('from 设备槽路');
QuerySBCL.SQL.Add('Where convert(int,substring(系统源槽路,5,5)) between 1 and 50 ');
中的convert(int,substring(系统源槽路,5,5))必须为表中的一个字段,
否则编译会现你所提到的错误信息.
QuerySBCL.SQL.Add('from 设备槽路 ');
QuerySBCL.SQL.Add('Where (系统源槽路 between ''1-1-1''and ''1-1-50'')');
QuerySBCL.SQL.Add('from 设备槽路 ');
QuerySBCL.SQL.Add('Where rtrim(系统源槽路) between ''1-1-1'' and ''1-1-50''');