[英]How to post data from last x rows with z columns from a table? (MYSQL/PHP)
In a database, is a table, atable, with 3 columns, id (autoincremented), title, and description. 在数据库中,是一个表,atable,有3列,id(自动增量),标题和描述。
How can you get the last 6 rows in the table and post the data as below: 如何获取表格中的最后6行并发布如下数据:
<div class="myclass">
<h1>Title</h1>
<p>Description</p>
</div>
The SQL you are looking for is like this: 您正在寻找的SQL是这样的:
SELECT Title, Description
FROM aTable
ORDER BY ID Desc
LIMIT 6
ORDER BY
the ID and then use LIMIT
. ORDER BY
的ID,然后使用LIMIT
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.