[ create a new paste ] login | about

Link: http://codepad.org/Em0pyyI8    [ raw code | output | fork ]

balajimca - PHP, pasted on Dec 7:
1
2
3
4
5
6
7
<?php
//get previous and next ids of current id using SQL query
echo "select field1, field2
     , ( select min(id) from yourtable where id > t.id ) as next_id
     , ( select max(id) from yourtable where id < t.id ) as prev_id
from yourtable as t  where id = 937";
?>


Output:
1
2
3
4
select field1, field2
     , ( select min(id) from yourtable where id > t.id ) as next_id
     , ( select max(id) from yourtable where id < t.id ) as prev_id
from yourtable as t  where id = 937


Create a new paste based on this one


Comments: