I tried the MySQL query given below. It works for the latter part, i.e. it gives category_id up to the maximum category_id. However, it gives all category IDs from the beginning (1), i.e. it does not start from "9".
SELECT columns FROM table_name WHERE (9 <= category_id <= ( SELECT category_id FROM table_name ORDER BY category_id DESC LIMIT 1 ) );
P粉2210464252023-09-10 19:32:46
Logically, your query is
SELECT { columns } FROM table_name WHERE 9 <= category_id;
There is no point in using a subquery condition - the column value cannot be greater than the maximum value in this column.