简体   繁体   中英

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:

the search for 'black box'

should return 'box black 32oz 2 pack', 'box black 32oz 4 pack'

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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM