Skip to content

Instantly share code, notes, and snippets.

@ctcherry
Created October 22, 2011 22:50
Show Gist options
  • Save ctcherry/1306594 to your computer and use it in GitHub Desktop.
Save ctcherry/1306594 to your computer and use it in GitHub Desktop.
SET @rows = 5;
SET @c = (SELECT COUNT(id) FROM table);
SET @c = @c - @rows;
SET @s = CONCAT("SELECT * FROM table LIMIT ", @c, ",", @rows);
PREPARE stmt FROM @s;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment