Skip to content

Instantly share code, notes, and snippets.

@mattpass
Last active December 24, 2015 13:31
Show Gist options
  • Select an option

  • Save mattpass/0124b79127da29118857 to your computer and use it in GitHub Desktop.

Select an option

Save mattpass/0124b79127da29118857 to your computer and use it in GitHub Desktop.
SQL - get number of rows from last query
SELECT SQL_CALC_FOUND_ROWS *, * FROM huge_table;
/* Then as 2nd query straight after... */
SELECT FOUND_ROWS() AS totalRows;
/* ...to get total records found */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment