怎么根据ID获取同一行中的某一个字段

WBOY
Release: 2016-06-13 12:56:37
Original
827 people have browsed it

如何根据ID获取同一行中的某一个字段
现在有字段 ID , BODY;
我现在根据ID=100获取了同一行的BODY,echo出body,

然后现在还要需要根据id+1 也就是 获取 ID=101 行的body 一样 echo出来。
获取下一个id的 body 这个要怎么写?


------解决方案--------------------
<br />
$sql = "SELECT * FROM `shops` WHERE `id` > '100' limit 1 order by id asc";<br />
$s = $db->getLine($sql);<br />
$shop = array(<br />
    'body'    =>    $s['body'],<br />
);<br />
Copy after login


------解决方案--------------------
<br />
$sql = "SELECT * FROM `shops` WHERE `id` = '101'";<br />
$s = $db->getLine($sql);<br />
$shop = array(<br />
    'body'    =>    $s['body'],<br />
);
Copy after login

------解决方案--------------------
传个参数进去吧
------解决方案--------------------
如果你是只是大1的话,还需要指limit
<br />
$sql = "SELECT * FROM `shops` WHERE `id` > '100' limit 1 order by id ASC limit 1";<br />
$s = $db->getLine($sql);<br />
$shop = array(<br />
    'body'    =>    $s['body'],<br />
);<br />
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template