现有A表字段有XM(姓名),sfcz(是否存在),另有表B、字段有xm(姓名)
现想找出A表和B表姓名相同的人,并在A表sfcz字段中输入汉字“有”。
程序如下:
procedure TForm1.Button1Click(Sender: TObject);
begin
query1.Close;
query1.SQL.Clear;
query1.SQL.Add('update A set sfcz ="有"' );
query1.SQL.Add('from  A, B ');
query1.SQL.Add('where A.XM = B.Xm ');
query1.prepare;
query1.ExecSQL;
end;
提示语法错误为操作符丢失在查询表达式[有]from A 中
不知如何修改.
注:(1)数据库为ACCESS2000
    (2) 'update A set sfcz =''有'''也不行    
    (3)用quotedstr('有')也不行

解决方案 »

  1.   

    'update a set sfcz=''有'' where xm in select xm from b
      

  2.   

    'update a set sfcz= '''有''' where xm in select xm from b
      

  3.   

    'update a set sfcz= '''有''' where xm in select xm from b'
      

  4.   

    'update a set sfcz= '+'''有'''+' where xm in select xm from b'
      

  5.   

    'update a set sfcz= '''有''' where xm in select xm from b'
      

  6.   

    呵呵,你这属于引号的疑问我以前碰见过: 在一台机器上必须用"   //双引号
     在另一台机器上必须用''  //两个单引号不知道为什么,到现在也是(可能是系统的字体bug)//猜的你多试试就行了, 就是引号的问题 :-)
      

  7.   

    解释专家:
    在SQL中:
    update a set sfcs='有' where xm im select xm from b 在DELPHI中:
    Adoquery1.sql.text:='update a set sfcs=''有'' where xm in select xm from b ' where xm=''%'+Edit1.text+'''';
    ;
    解释: 在DELPHI中,两个连续的''才输出一个',所以在sfcs=''有'' 中 当变成SQL语句时,
    就可以变成 sfcs='有';后面我加了一个EDIT1的是为了更好的说明问题:
    xm=''%' 即可转换成xm='  再连接EDIT1.TEXT ,最后的四个'''' 第一个与最后一个是DELPHI中的字符串的表示符,第二,三个是转换成 ' 的。
    明白了吗?
      

  8.   

    同意楼上, Delphi就是用''来转义'的. 所以:
    Showmessage('That''s Tom''s work.');
    输出为:
    That's Tom's work.
      

  9.   

    呵呵,告诉你一个最容易记的方法:query1.SQL.Add('update A set sfcz =' + QuotedStr('有'));
      

  10.   

    query1.Close;
    query1.SQL.Clear;
    query1.SQL.Add('update A set sfcz ='''有''' );
    query1.SQL.Add('where xm in (select xm from B ');
    query1.prepare;
    query1.ExecSQL;
      

  11.   

    注:(1)数据库为ACCESS2000
        (2) 'update A set sfcz =''有'''也不行    
        (3)用quotedstr('有')也不行
      

  12.   

    注:(1)数据库为ACCESS2000
        (2) 'update A set sfcz =''有'''也不行    
        (3)用quotedstr('有')也不行
      

  13.   

    我已做了例程,下面语法可通过
    update a set sfcz=''有'' where xm in (select xm from b)
    access不支持sql server里的一些语法。
    象楼主的那句语法在oracle里也通不过。
    如再有疑问,我可把那个例程发给你[email protected].