SQLSTATE[42S22] i have problem sql in laravel..

Posted 1 month ago by amin93je

Error code

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'YEAR(CURRENT_TIMESTAMP) - YEAR(seeker_DOB) BETWEEN 18 AND 17' in 'where clause' (SQL: select count(*) as aggregate from `job_seekers` where seeker_gender LIKE "%%" and seeker_state LIKE "%%" or `YEAR(CURRENT_TIMESTAMP) - YEAR(seeker_DOB) BETWEEN 18 AND 17`

my code

  $seeker = job_seeker::selectRaw('*, YEAR(CURRENT_TIMESTAMP) - YEAR(seeker_DOB) AS ages')
                            ->whereRaw('seeker_gender LIKE "%'.$request->input('dd-gender').'%"')
                            ->whereRaw('seeker_state LIKE "%'.$request->input('dd-state').'%"')
                            ->orWhere('YEAR(CURRENT_TIMESTAMP) - YEAR(seeker_DOB) BETWEEN 20 AND 30')
                            ->orderby('created_at', 'DESC')->paginate(15);

the problem is i cant use `YEAR(CURRENT_TIMESTAMP) - YEAR(seeker_DOB) , because its this..

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.