can anyone help me to do something similar to this i.e., use subquery to set the limit :
select * from table limit (select count (*) as max_limit from table);
Any help would be highly appreciated. thanks.
can anyone help me to do something similar to this i.e., use subquery to set the limit :
select * from table limit (select count (*) as max_limit from table);
Any help would be highly appreciated. thanks.
You need to use dynamic SQL because the LIMIT
parameters have to be literals.
SET @SQL = CONCAT('select * from table limit ',
(select count (*) as max_limit from table));
PREPARE stmt FROM @SQL;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;