Home >Backend Development >PHP Tutorial > 怎么根据ID获取同一行中的某一个字段
如何根据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 />
<br /> $sql = "SELECT * FROM `shops` WHERE `id` = '101'";<br /> $s = $db->getLine($sql);<br /> $shop = array(<br /> 'body' => $s['body'],<br /> );
<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 />