Reputation: 37
I have a sql:
Doctrine_Query::create()
->select('(t.a+t.b) as c')
->from('mytable t')
->where('t.c > 1');
it raise a "Unknown column c" error;
Anyone can help?
I have a try:
Doctrine_Query::create()
->select('(t.a+t.b) as c')
->from('mytable t')
->orderBy('t.c');
It's OK;
why?
Upvotes: 0
Views: 182
Reputation: 3523
I suspect if you are using MySQL it is because the WHERE clause does not support computed columns, you need to:
a) Repeat (t.a + t.b) > 1 in the where clause
b) use having (t.c > 1) instead of the Where clause
Upvotes: 1