D
D
Damir Shaniyazov2021-07-17 17:24:29
Laravel
Damir Shaniyazov, 2021-07-17 17:24:29

How to find matches across all columns in a table?

Good afternoon! Tell me how to find rows by coincidence from any column?

Here is an example

$users = DB::table('users')
                    ->where('votes', '>', 100)
                    ->orWhere('name', 'John')
                    ->get();


Here we will tell it is necessary to specify columns. Or you can simply not indicate what is needed for all columns.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2021-07-17
@shaniyazovdamir

It is forbidden. And yes, this problem comes up about once in a while.
But you can get the names of all fields with a separate request if you don't want to hardcode them. It's just easier to hardcode.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question