How does mysql query the next piece of data?
The editor will share with you how mysql queries the next piece of data. I hope you will gain a lot after reading this article. Let's discuss it together.
Mysql's method for querying the next piece of data: select a data larger than the current ID from the news table in the order from smallest to largest, with the code [table_a where id = (select min (id) from table_a where id > {$id})].
The method for mysql to query the next piece of data:
The principle of getting the next record in the current file is the next sql statement, which selects a piece of data larger than the current ID from the news table in order from smallest to largest.
If ID is a primary key or has an index, you can look for it directly:
Method 1:
1.select * from table_a where id = (select id from table_a where id
< {$id} order by id desc limit 1); 2.select * from table_a where id = (select id from table_a where id >{$id} order by id asc limit 1)
Method 2:
1.select * from table_a where id = (select max (id) from table_a where id)
< {$id}); 2.select * from table_a where id = (select min(id) from table_a where id >{$id}); after reading this article, I believe you have a certain understanding of how mysql queries the next piece of data. Want to know more about it. Welcome to follow the industry information channel. Thank you for reading!