I am trying to build a laravel query which should order values in a column named "competition_type" in this way: 'ATP - SINGLES', 'WTA - SINGLES', 'CHALLENGER MEN - SINGLES', 'CHALLENGER WOMEN - SINGLES', 'ITF MEN - SINGLES', 'ITF WOMEN - SINGLES' and I tried this query, but it does work...
$matches = Match::select()
->where('date', $date)->where('pick_score', '<>', '0');
$matches = $matches->orderBy('hour', 'ASC');
$matches = $matches->orderBy(Match::raw("case when competition_type in ('ATP - SINGLES', 'WTA - SINGLES") then -1 else competition_type end, competition_type'));
What should I change in order to make it work?
...'case when competition_type in ('ATP...
or it's just what you posted on stackoverflow? it's not escaped if that's the casehour
orcompetition_type
? thecompetition_type
is string. and if it is in'ATP - SINGLES', 'WTA - SINGLES''
, you want them first?