SELECT start_coins
FROM coins
ORDER BY start_coins DESC LIMIT 10; /* till here the query works*/
CAST((COUNT(start_coins) * 0.2) AS INT);
I want the number returning from the count to be used as the LIMIT instead of 10. My database version is 10.1.32-MariaDB.
Best Answer
The LIMIT clause parameters are always literals. So You cannot use the value calculated by some statement in it.
The solution can be in prepared statement use.
Variant 1:
Variant 2:
In both variants You MUST to execute all 4 statements in the same connection to database. The best vairant is the connector You use allows multi-statements (sending all statements as 1 command).