---
title: "mysql获取上一篇和下一篇文章的ID"
author: "kfcman"
date: "2013-01-31T00:33:35Z"
tags: []
categories: ["Web前端"]
slug: "mysql-id"
draft: false
lastmod: "2013-01-31T00:34:13Z"
id: 1780078
url: "https://kfcman.iteye.com/blog/1780078"
---

只要在当前页面读取上一个和下一个的ID就可以了。
假设当前ID为10：
搜索上一个的ID：select  id  from table where id<10 order by id desc  limit 0,1;
搜索下一个的ID：select  id  from table where id>10 limit 0,1;
