Scalar subquery in limit clause

I need to run a query like this:
When I do this I get AssertionError message.
Is it possible to use a scalar subquery in limit clause?

The SQL standard allows only literal constant, a parameter, or a variable name so python-sql allows only integer.
The usage of sub-query is an extension of PostgreSQL.

Solved the problem this way:

    query1 =
    query2 =

    query = ("%s" % query1).replace("LIMIT 0", "LIMIT (%s)" % query2)

    cursor = Transaction().connection.cursor()

Of course, DBMS must support the usage of scalar sub-queries.

It is way simpler and more portable to run the first query and put the result as limit of the second.

Oh sure. Thanks a lot.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.