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;
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;
不要把数据运算放到程序中,分开写
'where A.case_no='+'B.case_no and b.case_no='+Edit1.Text
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);
注意两点就行了:
1. SQL.add('');括号内为字符串,因此各SQL分句最前(或最后)留一空格;
2. 在where 子句中,当判断值的字段类型为字符型时,该值前后都应当用单引号(')括起来
但在Delphi的字符串中两个单引号('')代表一个引号(')