Q: How does the MySQL database query data in a certain range, such as data with IDs between 5-10?
Method 1:查询 id>=5 和 id<=10 的数据
实例:SELECT * FROM ceshi1 WHERE `id` >= 5 AND `id` <=10;
Suitable for scene: suitable for continuous range
Method 2: Use the between... and... syntax.
Example: SELECT * FROM ` ceshi1 ` WHERE ` id ` BETWEEN 5 AND 10;
Suitable for scene: suitable for continuous range
Method 3: Use the in... syntax.
Example: SELECT * FROM ` ceshi1 ` WHERE ` id ` IN (5,6,7,8,9,10);
Suitable for scene: suitable for discontinuous range