简体   繁体   English

使用SQL是否可以通过字符串搜索而无需考虑字符的顺序?

[英]Using SQL is it possible to search via string without regards to the order of the characters?

I would like to be able to search using a sql query without regarding the order of the characters within a string: 我希望能够使用sql查询进行搜索,而无需考虑字符串中字符的顺序:

the search for 'black box' 搜索“黑匣子”

should return 'box black 32oz 2 pack', 'box black 32oz 4 pack' 应返回“盒装黑色32盎司2包”,“盒装黑色32盎司4包”

currently it does not return any of it. 当前它不返回任何信息。

I must search by 'box black' to receive a query result 我必须按“黑匣子”进行搜索才能收到查询结果

SELECT DISTINCT Hetype.Description,
  Item.Type
FROM Item
  INNER JOIN Hetype ON Item.Type = Hetype.Type
WHERE Hetype.Description LIKE '%black box%' IGNORE CASE  

You can use two LIKE expressions: 您可以使用两个LIKE表达式:

WHERE Hetype.Description LIKE '%black%' IGNORE CASE AND
      Hetype.Description LIKE '%box%' IGNORE CASE

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SQL搜索包含字符的字符串 - SQL search for string containing characters 就SQL而言,使用XML有什么优势? - What is the advantage of using XML with regards to SQL? 在SQL中使用特殊字符作为字符串 - Using special characters in SQL as string 大写第一个字母,每个单词,修复可能的字符串拆分顺序问题,T-SQL 2017 中的多个分隔符,而不使用用户定义的函数 - Capitalize first letter, every word, fix possible string split order issues, multiple delimiters in T-SQL 2017 without using a user-defined function SQL查询使用前3个字符的邮政编码搜索 - Sql query Postcode search using first 3 characters 通过string.format生成的SQL查询字符串中的转义字符 - escape characters in SQL query string produced via string.format 对SQL ORDER BY查询进行排序,转义字符前不加斜杠 - Sort SQL ORDER BY query without slashes in front of escaped characters SQL存储过程字符串通过传递参数搜索并使用“LIKE”查询 - SQL Stored Procedure String Search via Passed Parameter and Using 'LIKE' query 是否可以使用SQL将值传递给order by子句? - Is it possible to pass a value to an order by clause using SQL? SQL Server存储过程搜索没有特殊字符的值列表 - SQL Server stored procedure to search list of values without special characters
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM