I am not a MySQL expert by any means, but after reading the documentation for the SELECT statement, I did not find an answer to my problem.
I have this statement:
SELECT COUNT(*)=x.c FROM someTable,
(SELECT COUNT(*) c
FROM someTable
WHERE firstId <= secondId) x;
And I’m trying to figure out what the x.c means in the context of the query? Specifically, what is with the x that seems to be hanging out there?
I interpret the nested SELECT as SELECT COUNT(*) as c, making an alias for the row count as c, is that what the x is as well? What would it be an alias for?
Thanks!
The
xis a table alias – a name for the nestedSELECTstatement in parentheses.Is a boolean condition that the total row count of
someTablebe equal to the row count ofsomeTablewherefirstId <= secondIdx.cis the column name for the count returned by the subquery.