By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
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.
Related Q&A from Rudy Limeback
Read SQL expert Rudy Limeback's advice for counting combinations in a table with SQL's GROUP BY clausecontinue reading
Read an example of an SQL case expression from our SQL expert Rudy Limeback.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.