[Zope-DB] Z SQL equivelant of MySQL's SQL_CALC_FOUND_ROWS?
dieter at handshake.de
Wed Nov 30 15:14:12 EST 2005
Kevin Monceaux wrote at 2005-11-29 13:20 -0600:
>I'm new to Zope so forgive me if the answer to this question is obvious. If
>one performs a select with a limit clause is it possible to determine how
>many results would have been returned if there was no limit? For example,
>if I wanted to select the first picture in a photo album but wanted to know
>the total number of pictures in the album, how would I do that via Z SQL?
>With MySQL it can be done this way:
>SELECT SQL_CALC_FOUND_ROWS, * from Pictures where AlbumID = 25 LIMIT 1;
>SELECT FOUND_ROWS() as Count;
>According to the "Z SQL Methods User's Manual" multiple SQL statements can
>be included in a Z SQL method but that no more than one select statement can
>be included. The above MySQL technique requires two select statements.
If you really want to use this esoteric feature (someone else
already proposed a more standard alternative), you
can put the two selects in different Z SQL Methods and call them
one after the other...
More information about the Zope-DB