Re: mysql query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2005-02-17 at 18:24, Sebastian wrote:
> Hello,
> im working on an article system and looking to avoid running three queries.
> example, i have this query:
> 
> SELECT id,title FROM articles WHERE id=$_GET[id]
> 
> now say $_GET[id] = 5
> 
> I would like to get the previous id 4 and the next id 6 (if there is one)
> so i can do something like:
> 

sure how about :

select id, title 
from articles 
where id >= $_GET[id] - 1 
and id <= $_GET[id] + 1
order by num;

should be valid sql but I have no experience with mysql

Bret

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux