I'm searching for something similar to this question, but for sqlite3
. Is this possible?
From SELECT/The LIMIT clause:
Any scalar expression may be used in the LIMIT clause, so long as it evaluates to an integer or a value that can be losslessly converted to an integer...
You can use directly the integer result of a subquery in the LIMIT
clause:
SELECT *
FROM table1
ORDER BY id
LIMIT (SELECT COUNT(*) FROM table2);
See a simplified demo.