RE: [PHP] Single SQL-statement in PHP to order...

From: Date: Tue, 19 Apr 2005 11:08:33 +0000
Subject: RE: [PHP] Single SQL-statement in PHP to order...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-213336@lists.php.net to get a copy of this message
> > Hi there! > > > > I guess this is off-topic? but I want to know if this is > possible. (If > > there's anyone out there that have a solution, I would appreciate it > > though) > > > > I want to know if there is anyway of showing tables in PHP > in an order > > like this in a single SQL-statement... > > > > Table is like this: > > IDCategory > > 7 > > 15 > > 4 > > 3 > > > > I want to order the table like this: First everything that is > > IDCategory 4, then the rest of the posts (doesn't matter > which order) > > SELECT *, 1 AS sequence FROM Table WHERE IDCategory = 4 UNION SELECT *, 2 AS sequence FROM Table WHERE IDCategory != 4 ORDER BY sequence ASC Jared

« previous php.general (#213336) next »