update tablename set 某字段="AAA" where 编号=A or 编号=B or.....where 编号 in (listbox1.items.(listbox1.intemindex),listbo2.items.(listbox2.intemindex,...))

解决方案 »

  1.   

    原来还有IN这个好东西,害得我想了好久。(listbox1.items.(listbox1.intemindex),listbo2.items.(listbox2.intemindex,...)) 中括号好象不大对吧,能不能把循环的代码的也一并写出?(listbox1.items.(listbox1.intemindex),listbo2.items.(listbox2.intemindex,...)) 这一段用变量str表示。
      

  2.   

     hericong(ifly) 的方法比较好
    update tablename set 某字段="AAA" where 编号=A or 编号=B or.....where 编号 in (listbox1.items.(listbox1.intemindex),listbo2.items.(listbox2.intemindex,...)) 
      

  3.   

    var
     wherestr:string
    begin
      wherestr:='编号 in '+listbox1.items.(listbox1.intemindex),listbox2.items.(listbox2.intemindex,...)) 
    end;
      

  4.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
      if ListBox1.Items.Count > 0 then
        ADOQuery.SQL.Text := Format('update tablename set 某字段="AAA" where 编号 IN (''%s'')',
        [StringReplace(Trim(ListBox1.Items.Text), #13#10, ''',''', [rfReplaceAll])]);
    end;
      

  5.   

    var
     wherestr:string
    begin
      wherestr:='编号 in '+listbox1.items.(listbox1.itemindex),listbox2.items.(listbox2.itemindex,...)) 
    end;
    是itemindex
      

  6.   

    嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻
    嘻嘻嘻请试试嘻嘻嘻嘻
    嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻procedure TForm1.Button1Click(Sender: TObject);
    begin
      if ListBox1.Items.Count > 0 then
        ADOQuery.SQL.Text := Format('update tablename set 某字段="AAA" where 编号 IN (''%s'')',
        [StringReplace(Trim(ListBox1.Items.Text), #13#10, ''',''', [rfReplaceAll])]);
    end;
      

  7.   

    var i:integer; str:string;
    begin
    str:='';
    for i:=0 to listbox1.Items.Count-1 do
    begin
         if i=listbox1.Items.Count-1 then
         str:=str+'编号='+''''+listbox1.Items[i]+''''
         else
        str:=str+'编号='+ '''' + listbox1.Items[i]+ '''' + ' or ';
    end;
    showmessage(str);
    end;
      

  8.   

    zswang(伴水)(伤心中) 写的正是我想要的,StringReplace是什么意思?伴水请答。
      

  9.   

    StringReplace的字面可以理解,我想知道后面的参数有哪些?