ptQuery.Close;
ptQuery.SQL.Clear;
ptQuery.SQL.Add('select A.pt_name,A.pt_sex,A.pt_age,B.pt_sort_id');
ptQuery.SQL.Add('from fz_ro_pt_baseinfo_h A,fz_ro_rg_register_h B');
ptQuery.SQL.Add('where A.case_no='+'B.case_no='+Edit1.Text);
ptQuery.Open;

解决方案 »

  1.   

    ptQuery.SQL.Add('where A.case_no='+'B.case_no='''+Edit1.Text+''' ');
      

  2.   

    'where A.case_no='+'B.case_no='+Edit1.Text
    不要把数据运算放到程序中,分开写
    'where A.case_no='+'B.case_no and b.case_no='+Edit1.Text
      

  3.   

    ptQuery.SQL.Add('where A.case_no='+'B.case_no='''+Edit1.Text+'''');
      

  4.   

    ptQuery.SQL.Add('   from fz_ro_pt_baseinfo_h A,fz_ro_rg_register_h B');
    ptQuery.SQL.Add('   where A.case_no='+'B.case_no='+Edit1.Text);
    前面要加空格
      

  5.   

    ptQuery.SQL.Add(' where A.case_no='+'B.case_no and A.case_no='+Edit1.Text);
      

  6.   

    ptQuery.SQL.Add('where A.case_no='+'B.case_no='+Edit1.Text);
    有错!!!!!
    ptQuery.SQL.Add(' where A.case_no='+'B.case_no and A.case_no='+Edit1.Text);
      

  7.   

    ptQuery.SQL.Add(' where A.case_no=B.case_no and A.case_no='''+Edit1.Text+'''');
      

  8.   

    楼上说得都对,但要
    注意两点就行了:
    1. SQL.add('');括号内为字符串,因此各SQL分句最前(或最后)留一空格;
    2. 在where 子句中,当判断值的字段类型为字符型时,该值前后都应当用单引号(')括起来
    但在Delphi的字符串中两个单引号('')代表一个引号(')