语句是这样的,高手解答下,谢谢
sql.Add('update chewei set panduan=0 where cwid=(select cwid from lscw where cpid=:id and panduan=1)  ');

解决方案 »

  1.   

    可以分开写啊。
    sqlstr:='select cwid from lscw where cpid=:id and panduan=1';
    sql.Add('update chewei set panduan=0 where cwid=sqlstr);
      

  2.   

    where cwid= 改成where cwid in 试试
      

  3.   

    id 参数赋值了吗,要保证你的select cwid from lscw where cpid=:id and panduan=1中唯一值,否则你在查询分析器里也执行不了.
      

  4.   

    错误信息是什么?你是用ExecSQL吗?
      

  5.   

    是唯一的值,而且我在查询分析器里可以改,就是在DELPHI中改不了,提示子查询返回值多于一个
      

  6.   

    id 的参数也设置了
    unit2.DataModule2.ADOQuery1.Parameters.ParamByName('id').Value:=edit2.Text;
      

  7.   

    select子查询返回的是一个集合,即使只有一个结果,所以要用in
      

  8.   

    where cwid= 改成where cwid in 
      

  9.   


    update chewei set panduan=0 where cwid in (select cwid from lscw where cpid=1 and panduan=1)
      

  10.   


    with adoquery1 do 
    begin 
    Close;
    SQL.Clear;
    SQL.Add('update chewei set panduan=0 where cwid=(select cwid from lscw where cpid=:id and panduan=1)');
    ExecSQL;end
      

  11.   

    我在查询分析器里运行
    update chewei set panduan=0 where cwid=(select cwid from lscw where cpid=001 and panduan=1)
    可以把chewei表里的panduan=0但是我在DLEPHI中写这条代码
    sql.Add('update chewei set panduan=0 where cwid=(select cwid from lscw where cpid=id and panduan=1)  ');
    unit2.DataModule2.ADOQuery1.Parameters.ParamByName('id').Value:=edit2.Text;
    id我也定义了(要求输入)
    当我输入001的时候就会出错,而且当我把in代替=的时候也出错,高手来解答下啊
    错误提示:子查询返回值多余一个,当子查询跟在=,!=,。。后,或子查询用做表达式时,这种情况不允许。
      

  12.   

    问题已经解决了,我重新启动了下DELPHI后就可以了。
    多谢各位!!!