I want to use orderBY on several Columns, but they should act like one single column. The table looks something like that:
col1 | col2
5 |
2 |
| 3
7 |
| 1
| 1
The result should look like that:
col1 | col2
| 1
| 1
2 |
| 3
5 |
7 |
If we would be using raw SQL there would be Methods, like using COALESCE
.
But how could this be achieved in the Doctrine QueryBuilder?
Edit:
I tried the orderBy like this:
qb->orderBy("COALESCE(col1, col2)", "DESC");
And like this
qb->add("orderBy", "COALESCE(col1, col2) DESC");
But both times I was thrown the following Error:
[Syntax Error] line 0, col 700: Error: Expected end of string, got '('