I make this query:
public static function searchYear($year)
{
return DB:: table('contract_works')
->select(DB::raw('Year(dateFailure) as dt'))
->where('dt',$year)
->orderBy('dt','asc')
->get();
}
but it tells me that the field does not exist, getting this error:
SQLSTATE [42S22]: Column not found: 1054 Unknown column 'dt' in 'where clause' (SQL: select Year (dateFailure) as dt from% co_of% where% co_of% = 1970 order by% co_of% asc)