单字段多条件模糊查询的Sql语句该如何写 比如想查询某个字段里所有包含
字符串str1 或者 包含字符串str2 或者 包含字符串str3的所有数据 该怎么写??

解决方案 »

  1.   

    我自己写了一个 Sql.text := 'select * from table1 where XX like  qute('%' + str1 +'%') union 'select * from table1 where XX like  qute('%' + str2 +'%') union 'select * from table1 where XX like  qute('%' + str1 +'%')';
    可是查询的时候 总提示 '内存溢出'  (字段里面没有日文片假名之类的字符)
      

  2.   

    用OR连接条件:select * from table1 where (XX like '%11%) OR (XX like '%22%)
      

  3.   

    我觉得应该不是 union 或 or 的问题
      

  4.   

    Sql.text := 'select * from table1 where XX like  ''%' + quotedstr(str1) +'%''' + 
                ' or  XX like  ''%' + quotedstr(str2) +'%''' + 
                ' or  XX like  ''%' + quotedstr(str3) +'%'''  
      

  5.   

    select a,b,c from table where 
    ((a like '%'+'+trim(RzComboBox72.Text)+'+'%') OR 
     (b like '%'+'+trim(RzComboBox72.Text)+'+'%') OR 
     (c like '%'+'+trim(RzComboBox72.Text)+'+'%')) 
    ........