MYSQL Select from table, get newest/last 10 rows in table

后端 未结 4 1620
礼貌的吻别
礼貌的吻别 2021-02-04 09:50

What\'s the best, and easiest way to do this? My query currently is:

  SELECT * 
    FROM chat 
   WHERE (userID = $session AND toID = $friendID) 
      OR (use         


        
4条回答
  •  礼貌的吻别
    2021-02-04 10:10

    If you want the last 10 then just change ASC to DESC

    SELECT * 
    FROM 
    chat 
    WHERE 
    (userID=$session AND toID=$friendID) 
    OR 
    (userID=$friendID AND toID=$session) 
    ORDER BY id 
    DESC
    LIMIT 10
    

提交回复
热议问题