| Author |
Problem with column alias: Unknown column 'avg_rating' in 'where clause'
|
Julien Martin
Ranch Hand
Joined: Apr 24, 2004
Posts: 383
|
posted

0
|
Hello, I have a basic sql statement as follows: I have used a column alias for "avg(r.rating)" and named it "avg_rating". It works in my Mysql Query browser without problem but when I run it from Java I get this: Can anyone help please? Thanks in advance, Julien Martin.
|
 |
Em Aiy
Ranch Hand
Joined: May 11, 2006
Posts: 225
|
|
|
use 'as' between avg(r.rating) avg.rating
|
The difference between <b>failure</b> and <b>success</b> is often being <b>right</b> and being <b>exactly right</b>.
|
 |
Julien Martin
Ranch Hand
Joined: Apr 24, 2004
Posts: 383
|
posted

0
|
Hello Muhammad, Thanks for the reply. However I still get the same exception after introducing the change: avg(r.rating) as avg_rating any other idea? Julien
|
 |
Em Aiy
Ranch Hand
Joined: May 11, 2006
Posts: 225
|
|
well, looking at the errors, the where clause is unable to recognize the column. replace the avg_rating >= 1 to avg(rt.rating). You can't use the alias in "where" clause, the where clause must be provided with the column names already defined in database. I hope this will work.
|
 |
 |
|
|
subject: Problem with column alias: Unknown column 'avg_rating' in 'where clause'
|
|
|