I want to count records of query. The problem is that the query is not constant.
I write something like this, but this is only almost good
select count(*) from (select * from users);
String query = "select * from users";
String queryCount = "select count(*) from (" + query + ")";
ERROR 1248 (42000): Every derived table must have its own alias
select count(*) from (select * from users) as alias;
there needs to be some name for result set that is generated by the query in brackets.