Gooseman
Gooseman

Reputation:

SQL_CALC_FOUND_ROWS question when using two ORDER BYs

I have a query that gets a result, limits it and then does a sort around the limited results. Something like:

(SELECT SQL_CALC_FOUND_ROWS * FROM  table ... ORDER BY score DESC LIMIT 0,15) ORDER BY name ASC;

Using

SELECT FOUND_ROWS() AS total

after will always return 15 due to the sub sort. Is there a way around this?

Thanks!

Upvotes: 1

Views: 103

Answers (1)

Quassnoi
Quassnoi

Reputation: 425623

I'm afraid you'll have to do a COUNT(*) in a separate query.

Upvotes: 1

Related Questions