Re: mysql query

From: Date: Fri, 18 Feb 2005 04:02:14 +0000
Subject: Re: mysql query
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-208985@lists.php.net to get a copy of this message
On 17 Feb 2005 19:28:18 -0600, Bret Hughes <bhughes@elevating.com> wrote: > 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: I would do something like: $theId = $_GET['id']; $ids = $theId-1 . ", ". $theId ", ". $theId+1; $query = "SELECT id, title FROM articles WHERE id IN ($ids)";

« previous php.general (#208985) next »