Re: divide-column?

From: Date: Tue, 30 Aug 2005 08:31:02 +0000
Subject: Re: divide-column?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-221569@lists.php.net to get a copy of this message
Murray @ PlanetThoughtful wrote:
Hi there! How do I do a sort in PHP where a column in a db must be two other columns divided...`?
<snip> Hi Gustav, You should be able to use the divide operation in your query's ORDER BY clause. Eg SELECT * FROM mytable ORDER BY (field1 / field2)
You might need to do: SELECT *, (field1 / field2) AS divField FROM mytable ORDER BY divField as I'm not sure if you can use expressions like that in the ORDER BY clause. Maybe... -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ If you find my advice useful, please consider donating to a poor student! You can choose whatever amount you think my advice was worth to you. http://tinyurl.com/7oa5s

« previous php.general (#221569) next »