Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有这样的事情:
$sql = $con->query("SELECT * FROM Content ORDER BY Time DESC LIMIT 2"); while ($row = $sql->fetch()) { echo $row['title']; }
所以这会抓取表中的 2 个最新条目,然后回显指定的列。如何从我的表中获取第二个和第三个最近的条目而忽略第一个?
现在我正在考虑将限制设置为 3 并以某种方式跳过第一个结果并抓住剩下的 2 个。
试试这个 :
LIMIT 1,2
1 => 偏移量:从哪里开始(第一个将是 0) 2 => 记录数
$sql = $con->query("SELECT * FROM Content ORDER BY Time DESC LIMIT 1,2"); while ($row = $sql->fetch()) { echo $row['title']; }