Skip to content
Advertisement

How to search a row to see if any of the columns contain a certain string? In SQL

I have a table with 10 columns that each contain string values. I want to run a query that will return any of the rows which have any column value that matches a given string or set of strings.

Is there any way to do this?

The DBMS is MsSQL

Advertisement

Answer

if you want exact match, you can use IN keyword and check in all columns

if you want partial match then you have to use LIKE

or you can add all columns and do one LIKE check

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement