标签:pre like class 字符 rom des 查询语句 bottle delphi
SQLString :=
‘SELECT * FROM XXX_XX_XXXX_STATUS_CHANGE_HIST ‘+
‘WHERE RESISTNAME LIKE ‘‘‘+ComboBox1.Text+‘‘‘||‘‘%‘‘ ‘+
‘AND BATCHNO LIKE ‘‘‘+ComboBox4.Text+‘‘‘||‘‘%‘‘ ‘+
‘AND BOTTLENO LIKE ‘‘‘+ComboBox2.Text+‘‘‘||‘‘%‘‘ ‘+
‘AND EQPID LIKE ‘‘‘+ComboBox3.Text+‘‘‘||‘‘%‘‘ ‘+
‘AND STATUS LIKE ‘‘‘+ComboBox5.Text+‘‘‘||‘‘%‘‘ ‘+
‘AND MODIFYTIME > ‘‘‘+(FormatDateTime(‘yyyy-mm-dd‘,DateTimePicker1.date))+‘‘‘ ‘+
‘AND MODIFYTIME < ‘‘‘+(FormatDateTime(‘yyyy-mm-dd‘,DateTimePicker2.date+1))+‘‘‘ ‘+
‘ORDER BY MODIFYTIME DESC‘;
在SQL的模糊查询符%的两边,用的两个单引号,为什么是两个不是一个呢。新手求解
两个表示包含了单引号这个符号。
举例:
a:=‘abc‘;
那么a里面实际存的是:abc
b:=‘‘‘abc‘‘‘;
那么b里面实际存的是:‘abc‘
c:=‘ab‘‘c‘;
c里面实际存的是:ab‘c
一个是delphi字符串的引号,一个是sql拼接的作为条件的引号。
‘SELECT * FROM XXX_XX_XXXX_STATUS_CHANGE_HIST ‘+
‘WHERE RESISTNAME LIKE ‘‘‘+ComboBox1.Text+‘‘%‘‘ ‘+
‘AND BATCHNO LIKE ‘‘‘+ComboBox4.Text+‘‘%‘‘ ‘+
‘AND BOTTLENO LIKE ‘‘‘+ComboBox2.Text+‘‘%‘‘ ‘+
‘AND EQPID LIKE ‘‘‘+ComboBox3.Text+‘%‘‘ ‘+
‘AND STATUS LIKE ‘‘‘+ComboBox5.Text+‘‘%‘‘ ‘+
‘AND MODIFYTIME > ‘‘‘+(FormatDateTime(‘yyyy-mm-dd‘,DateTimePicker1.date))+‘‘‘ ‘+
‘AND MODIFYTIME < ‘‘‘+(FormatDateTime(‘yyyy-mm-dd‘,DateTimePicker2.date+1))+‘‘‘ ‘+
‘ORDER BY MODIFYTIME DESC‘;
可以用Quotedstr函数
SELECT * FROM XXX_XX_XXXX_STATUS_CHANGE_HIST ‘+
‘WHERE RESISTNAME LIKE ‘+Quotedstr(ComboBox1.Text+‘%‘)
...
delphi开发环境,写SQL的查询语句,这个单引号是怎么用的,如下
标签:pre like class 字符 rom des 查询语句 bottle delphi
原文地址:https://www.cnblogs.com/jijm123/p/13369600.html