The first data from the SQL query tables and the last piece of data

Method One: Use TOP

  1. SELECT TOP 1 * FROM user;  
  2. SELECT TOP 1 * FROM user order by id desc;  

 

Option two: LIMIT

      1. SELECT * FROM user LIMIT 1;  
      2. SELECT * FROM user ORDER BY id ASC LIMIT 1;  
      3. SELECT * FROM user ORDER BY id DESC LIMIT 1;  

Reprinted to: https://www.cnblogs.com/weimingxin/p/7929584.html

Guess you like

Origin www.cnblogs.com/max-hou/p/10990531.html