A
A
Anatoly2018-05-14 20:06:55
ORM
Anatoly, 2018-05-14 20:06:55

How to organize such a request in ORM?

Hello.
How to organize a request in ORM with the condition that 2 fields are not equal?
I need to select all records that have ID != OTHER_FIELD?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya, 2018-05-14
@les-anatoliy

$books = Book::with('authors')->whereRaw('id != other_field')->get();

P
pLavrenov, 2018-06-04
@pLavrenov

It is possible like this:
Book::where('id, '!=', 'other_field')->get();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question