N
N
NataliaCh2019-03-01 12:06:19
SQL
NataliaCh, 2019-03-01 12:06:19

How to search across multiple fields in a table?

There is a table containing a bunch of fields, including a dozen text fields.
Is it possible to build a query in such a way that it searches for a specific word in all text fields? For example "test".
Of course, you can spawn a bunch of LIKEs. Or write a script (I work in php) that will generate all these likes so as not to write manually. But I wonder if it is possible to do it beautifully using SQL? And if possible, I would like to see an example :)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2019-03-01
@NataliaCh

you can add (text string concatenation) all columns and search as a result of addition - there will be less LIKEs and ORs

A
Artem Cherepakhin, 2019-03-01
@AltZ

It is possible to make through the data dictionary the truth already by means of Transact-SQL.
https://professorweb.ru/my/sql-server/2012/level3/...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question