Postgresql – How to search for a string in all columns of a table

postgresqlstring-searching

I use postgresql database and the need is to return all the rows that contain a given string in any column of that table. For example, I have a table like this.

enter image description here

I need a query to return all rows that has Italy in any of their columns i.e the query shoud return 1st and 3rd rows.

Best Answer

You can use an IN condition for that:

select *
from the_table
where 'Italy' IN (name, native, place);