Guarantees when using user variables to number rows
问题 Using user variables to number rows I often find answers here on SO suggesting the use of user variables to number some thing or other. Perhaps the clearest example would be a query to select every second row from a given result set. (This question and query is similar to this answer, but it was this answer which actually triggered this question here). SELECT * FROM (SELECT *, (@row := @row + 1) AS rownum FROM (SELECT @row := 0) AS init, tablename ORDER BY tablename.ordercol ) sub WHERE