Re: querying for values inside range

From: Date: Tue, 18 Mar 2003 11:09:17 +0000
Subject: Re: querying for values inside range
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-140104@lists.php.net to get a copy of this message
At 06:04 18-3-03 -0500, Jason Paschal wrote:
this is an sql syntax question and i know it's not appropriate for this mailing list, but i didn't want to subscribe to another mailing list for something i think one of you might be able help me with. thank you for your patience. i'm building a site utilizing PHP/MySQL. i'm querying a table to find records where a field lies within a certain range. $age1 = "20"; $age2 = "30"; $sql = "select * from table where age>=$age1 and age<=$age2";
"select * from table where age between $age1 and $age2";
is there another way to write this query? i'm going to be building the sql string programmatically and i was curious about different syntax being able to produce the same result in the hopes that it'll help streamline my PHP code. for example, what if i don't know which is value is greater, age1 or age2? is there some sql syntax that will deal with this situation without me having to determine which is which via PHP? _________________________________________________________________ Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#140104) next »