Re: ? Sort by a summation of columns ?

From: Date: Sun, 26 Nov 2000 04:04:46 +0000
Subject: Re: ? Sort by a summation of columns ?
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-4735@lists.php.net to get a copy of this message
You can try your own suggestion, but it won't work. How about "SELECT v1+v2+v3+v4+v5 AS sumofv FROM ... ORDER BY sumofv"? By the way, pretend that I wrote about two or three paragraphs about how you should make absolutely positive that your table should be designed that way because it's usually not very relational-like to store arrays that way. Doug At 06:43 AM 11/25/00 -0500, Noah Spitzer-Williams wrote: >I have a database setup as follows: > >some fields... | v1 | v2 | v3 | v4 | v5 >some fields... | v1 | v2 | v3 | v4 | v5 >some fields... | v1 | v2 | v3 | v4 | v5 > > >how can i retrieve a list of these rows sorted by the sum of v1 + v2 + v3 + >v4 + v5? > >for instance, can i do like : ORDER BY sum(v1,v2,v3,v4,v5)? > >- Noah > >-- Thanks! >

« previous php.db (#4735) next »