1

Is it possible to search in multiple columns for the same word and get every row (no matter in which column the word stands) as a result?

For example: I have a database consisting of 5 columns and hundreds of rows. Lets say the word "cat" stands in column 1 - row 1 AND in column 4 - row 50. Is it possible to write a query like 'search whole table for "cat"', so that I will get row 1 and row 50 as the result?

(I know that I can search for "cat" in one column, but I want to search over the whole table)

YHa
  • 11

1 Answers1

0

You need to specify the criteria by column and connect them by OR:

SELECT * 
FROM <table_name> 
WHERE 
  <column1> LIKE "*cat*" OR 
  <column2> LIKE "*cat*" OR 
  <column3> LIKE "*cat*" OR 
  <column4> LIKE "*cat*"`