I just got a 1054 Unknown column x.y in order clause
error inside phpMyAdmin on a query where I did not expect it, because
- The query used did not contain an ORDER clause.
- The query used cannot be faulty since it works fine on a database with the identical table schema.
The problem came up after I stopped a long running query by simply killing the mysql daemon from XAMPP Control panel.
A REPAIR TABLE x
didn't help. I got rid of the problem by explicitly querying the column that allegedly doesn't exist (SELECT x.y FROM x
) and then doing my query again - which then worked.
Is it possible that stopping the mysql process like I did is the reason for this symptom?
EDIT: The query that produced the said error:
SELECT * FROM x AS tblA
INNER JOIN (
SELECT z, y, COUNT(*) AS count
FROM x
GROUP BY z, y
HAVING count > 1
) tblB
ON tblA.z = tblB.z AND tblA.y = tblB.y
EDIT 2: The original query that was running on a 300k row table when I killed mysql:
SELECT * FROM x AS temp1
INNER JOIN ( SELECT z, y, Count(*) AS count FROM x GROUP BY z, y HAVING Count > 1 ) temp2
ON temp1.z = temp2.z AND temp1.y = temp2.y
RIGHT JOIN
(
SELECT DISTINCT whole.v FROM x AS tblA
INNER JOIN ( SELECT z, y, Count(*) AS count FROM x GROUP BY z, y HAVING Count > 1 ) tblB
ON tblA.z = tblB.z AND tblA.y = tblB.y
RIGHT JOIN ( SELECT * FROM x ) whole
ON tblA.v = whole.v AND tblA.w = whole.w
WHERE tblA.v IS NULL
) temp3
ON temp1.v != temp3.v