DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: webb123
今日帖子: 1
在线用户: 3
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 congrui (cr) ★☆☆☆☆ -
普通会员
2003/5/6 14:57:37
标题:
怎样除去字符串中第一个出现的词呀?(多谢) 浏览:2943
加入我的收藏
楼主: 例如 :sqlstr:='select * from tablename where and (条件1) and (条件2)

怎样才能变为sqlstr:='select * from tablename  where (条件1) and (条件2)

除去第一个and.

----------------------------------------------
-
作者:
女 123 (猪猪) ★☆☆☆☆ -
盒子活跃会员
2003/5/6 15:02:14
1楼: 简单,copy()函数就可以。
----------------------------------------------
-
作者:
男 congrui (cr) ★☆☆☆☆ -
普通会员
2003/5/6 15:16:06
2楼: 我是初学者,能用上面的例子帮我做个示范么?谢了

很是感谢!
----------------------------------------------
-
作者:
女 321 (321) ★☆☆☆☆ -
普通会员
2003/5/6 21:02:55
3楼: 这个是以前站长的一个程序中的代码,你参考一下:
procedure Tfrm_YQ_Lab.SpeedButton1Click(Sender: TObject);
var
  SQLStr,SQLAll,Log:String;
  SQLTemp:Pchar;
  arrstr:array[1..7]of String;
  i,l:integer;
  function getsth(CurrEdit:TEdit):boolean;
  begin
    result:=false;
    if CurrEdit.Text<>' then
      result:=true;
  end;
begin
  SQLAll:=';
  SQLStr:='SELECT * FROM "仪器库.db" WHERE ';
  if RadioGroup1.ItemIndex=1 then Log:='OR' else Log:='AND';
  if Getsth(Edit_name) then
    arrstr[1]:='(仪器名称=''+Edit_name.Text+'')';
  arrstr[2]:=ComboBox1.text;
  if arrstr[2]<>' then
    arrstr[2]:='(状况=''+arrstr[2]+'')';
  if Getsth(Edit_No) then
    arrstr[3]:='(型号=''+Edit_No.Text+'')';
  if Getsth(Edit_date) then
    arrstr[4]:='(启用日期=''+Edit_date.Text+'')';
  if GetSth(Edit_address) then
    arrstr[5]:='(放置位置=''+Edit_address.Text+'')';
  if GetSth(Edit_experi) then
    arrstr[6]:='(所属实验=''+Edit_experi.Text+'')';
  arrstr[7]:=';
  for i:=1 to 6 do
  begin
    arrstr[7]:=arrstr[7]+arrstr[i];
    if arrstr[i]<>' then
      SQLAll:=SQLAll+Log+arrstr[i];
  end;
  if arrstr[7]=' then
  begin
    showmessage('没有查询项目?');
    exit;
  end;
  
  l:=strlen(Pchar(SQLAll));
  GetMem(SQLTemp,l);
  SQLTemp^ := Chr(0);

  if SQLAll[1]='O' then
    StrCat(SQLTemp,Pchar(SQLAll)+2); //这部分就是去掉多余的OR
  if SQLAll[1]='A' then
    StrCat(SQLTemp,Pchar(SQLAll)+3);

  SQLStr:=SQLStr+SQLTemp+' ORDER BY 仪器名称,型号,启用日期,状况,放置位置,所属实验';
  FreeMem(SQLTemp);
//  Application.MessageBox(Pchar(SQLStr),'预查询的SQL语句',MB_OK);

  with Query1 do
  begin
    SQL.Clear;
    SQL.Add(SQLStr);
    Prepare;
    ExecSQL;
    Open;
  end;
end;
----------------------------------------------
-
作者:
男 congrui (cr) ★☆☆☆☆ -
普通会员
2003/5/7 8:32:56
4楼: 谢谢大哥们了:)
----------------------------------------------
-
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行84.96094毫秒 RSS