Most examples of LIKE use a table column as the value to search in, with the string supplied by the user as the value to search for. For example, say you have a products table, and the user enters the string 'ultra':
SELECT id , description FROM products WHERE description LIKE '%ultra%'
This query finds all products where 'ultra' (the value to search for) is located somewhere within the product description (the value to search in).
In your case, you want to have the string supplied by the user as the value to search in, with the cat_num column as the value to search for. All you need to do is reverse the normal sequence, and append the necessary wildcards, like this:
SELECT cat_num FROM yourtable WHERE 'This piece of wire has 902S type ...' LIKE '%' || cat_num || '%'
Here, the double pipes are the standard SQL concatenation operator.
Dig Deeper on Oracle development languages
Related Q&A from Rudy Limeback
Read an example of an SQL case expression from our SQL expert Rudy Limeback. Continue Reading
Read SQL expert Rudy Limeback's advice for counting combinations in a table with SQL's GROUP BY clause Continue Reading
Read about the Mimer Validator, a tool used to verify your SQL code, in this tip from SQL expert Rudy Limeback. Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.