我想做合并查询,代码如下:
choice:=combobox1.text;
content:=edit1.Text;
choice1:=combobox4.Text;
content1:=edit2.Text;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQl.add('select * from xuesheng_table where ('+choice+'
like ''%'+content+'%'')and');
adoquery1.sql.Add('('+choice1+' like ''%'+content1+'%'')');
adoquery1.Open;请教下执行的SQL语句错在哪里 (like附近有语法错误)
choice:=combobox1.text;
content:=edit1.Text;
choice1:=combobox4.Text;
content1:=edit2.Text;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQl.add('select * from xuesheng_table where ('+choice+'
like ''%'+content+'%'')and');
adoquery1.sql.Add('('+choice1+' like ''%'+content1+'%'')');
adoquery1.Open;请教下执行的SQL语句错在哪里 (like附近有语法错误)
adoquery1.SQl.add('select * from xuesheng_table where ('+choice+
' like ''%'+content+'%'') and ');
adoquery1.sql.Add('('+choice1+' like ''%'+content1+'%'')');
adoquery1.SQl.add('select * from xuesheng_table where ('+choice+
' like ''%'+content+'%'') and ');
adoquery1.sql.Add('('+choice1+' like ''%'+content1+'%'')');
adoquery1.SQL.Clear;
adoquery1.SQl.add('select * from xuesheng_table where ('+choice+'
like ''%'+content+'%'')and');
adoquery1.sql.Add('('+choice1+' like ''%'+content1+'%'')');
edit1.text:=sql.text;
//adoquery1.Open;
加个EDIT把SQL显示出来, 一看不就明白了.
adoquery1.SQL.Clear;
adoquery1.SQl.add(Format('select * from xuesheng_table where ( %s
like '%%s%') and %s like '%%s%')' , choice, content, choice1,content1);
like ''%'+content+'%'')and');
-------------〉 adoquery1.SQl.add('select * from xuesheng_table where ('+choice+'
like ''%'+content+'%'') and');