select * from you_table_name where (自定的查询条件) like [数据库的某个字段的开始的几个字符%] go
select * from 表 where 字段 like 'a%' ---查找的是以 a 开头的数据 select * from 表 where 字段 like 'ac%' ---查找的是以 ac 开头的数据
select * from tablename where 字段 like '%a%';
select * from table where field like 'AA%' table:表名 field:字段名 AA:开始字符
query2.Close; query2.sql.Clear; query2.sql.Add('select a.产品型号,b.签订日期,a.合同编号,b.客户名称,a.数量,a.金额 from 合同内容档案 a,合同档案 b'); query2.sql.Add('where a.产品型号 like '9%'); query2.sql.Add(' where b.统计编号=a.合同编号 and b.签订日期>:date1 and b.签订日期<:date2 order by 签订日期'); query2.Prepare; 这段老是报错,请问为何???
报什么错? query2.sql.Add('where a.产品型号 like '9%'); where 前空格 加了?
[Error] table_CXTJ2.pas(72): Missing operator or semicolon
query2.sql.Add('where a.产品型号 like ''9%'' ');
query2.Close; query2.sql.Clear; query2.sql.Add('select a.产品型号,b.签订日期,a.合同编号,b.客户名称,a.数量,a.金额 from 合同内容档案 a,合同档案 b'); query2.sql.Add(' where b.统计编号=a.合同编号 and a.产品型号 like ''99%'' and b.签订日期>:date1 and b.签订日期<:date2 order by 签订日期'); query2.Prepare; query2.Params[0].AsString:=trim(AdvComboBox_jqxh.Text); query2.Params[1].AsDate:=DateTimePicker1.Date; query2.Params[2].AsDate:=DateTimePicker2.Date; query2.Open;机器报错 list index out of bounds(2)请问各位还有什么地方有问题??
go
select * from 表 where 字段 like 'ac%' ---查找的是以 ac 开头的数据
table:表名
field:字段名
AA:开始字符
query2.sql.Clear;
query2.sql.Add('select a.产品型号,b.签订日期,a.合同编号,b.客户名称,a.数量,a.金额 from 合同内容档案 a,合同档案 b');
query2.sql.Add('where a.产品型号 like '9%');
query2.sql.Add(' where b.统计编号=a.合同编号 and b.签订日期>:date1 and b.签订日期<:date2 order by 签订日期');
query2.Prepare;
这段老是报错,请问为何???
query2.sql.Add('where a.产品型号 like '9%'); where 前空格 加了?
query2.sql.Clear;
query2.sql.Add('select a.产品型号,b.签订日期,a.合同编号,b.客户名称,a.数量,a.金额 from 合同内容档案 a,合同档案 b');
query2.sql.Add(' where b.统计编号=a.合同编号 and a.产品型号 like ''99%'' and b.签订日期>:date1 and b.签订日期<:date2 order by 签订日期');
query2.Prepare;
query2.Params[0].AsString:=trim(AdvComboBox_jqxh.Text);
query2.Params[1].AsDate:=DateTimePicker1.Date;
query2.Params[2].AsDate:=DateTimePicker2.Date;
query2.Open;机器报错 list index out of bounds(2)请问各位还有什么地方有问题??