Filix_suo
Filix_suo

Reputation: 37

doctrine unknown column

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

Answers (1)

Stephen Senkomago Musoke
Stephen Senkomago Musoke

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

Related Questions