Rajasekar D
Rajasekar D

Reputation: 560

Laravel Eloquent where between two column from Table

What is the Laravel eloquent query for this:

select * from `jobs` where 1 between min_experience and max_experience;

I tried the below query but this one encapsulates the where 1 with single quotes.

Job::whereRaw('? between min_experience and max_experience',1)->get();

select * from `jobs` where '1' between min_experience and max_experience;

Upvotes: 3

Views: 12703

Answers (3)

Vahid Alvandi
Vahid Alvandi

Reputation: 612

operator must like this

level_rank::where('min_pv', '>=', $pv)->where('max_pv', '<=', $pv)->first();

Upvotes: 0

Karvannan Thi
Karvannan Thi

Reputation: 56

Laravel have whereBetween query will work

Job::whereBetween('max_experience', [1, 1])->get();

Upvotes: -4

Alexey Mezenin
Alexey Mezenin

Reputation: 163758

Probably this will work for you:

Job::where('min_experience', '<', 1)->where('max_experience', '>', 1)->get();

Upvotes: 10

Related Questions