sqlwildcardsql-likenexusdb

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  


Solution

  • You can use two LIKE expressions:

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