Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Not a Bug
-
None
-
AWS
Description
This query works in MySQL, but will not run in MariaDB. Why?
select user_id as uID, last_name, first_name, athlete, parent, coach, code, |
sum(points) as total, |
propoints as lifetime, |
(select count(*) / 7 from |
(select count(user_id), Date(created_at) AS DATE |
from user_propoints |
where user_id = uID |
group by date) as ac1) |
as activity |
from user_propoints |
left join users on users.id = user_id |
left join countries on users.country = countries.id |
group by user_id |
order by total desc |
Output from MariaDB:
Error in query (1054): Unknown column 'uID' in 'where clause'
|
Attachments
Issue Links
- links to
I'd say that MariaDB is correct and MySQL contradicts its own manual. Quoting https://dev.mysql.com/doc/refman/8.0/en/problems-with-alias.html
and
So, only GROUP BY, ORDER BY, and HAVING clauses are valid places where you can use a column alias, not a WHERE clause of the subquery in the SELECT list.