List:General Discussion« Previous MessageNext Message »
From:Rory McKinley Date:January 14 2004 7:39am
Subject:Re: Using BETWEEN or <= >=
View as plain text  
On 13 Jan 2004 at 10:11, Eve Atley wrote:

> 
> I am attempting to construct a select statement in which I can find values
> between two fields: start, and end. I have tried using "BETWEEN" and
> comparing with <= and >=, but neither meet success. Can someone please set
> me straight? This is meant to be in a PHP page, but I'm assuming the syntax
> is similar if not the same. I understand there is also a min/max, but I'm
> not sure it would work in this instance.
> 
> $sql = "SELECT * FROM federal-married WHERE start >= ".$_POST['salary']."
> AND end <= ".$_POST['salary'];
> 
> --------------------
> Table: federal-married (finds federal tax rate based on marital status)
> start = min field, ie. 804
> end = max field, ie. 2801
> $_POST['salary'] = salary of individual posted from a form
> 
> 
> 
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
> 
> 
Hi Eve

If I assume that you are looking for a salary that lies between the values stored in the 
start and end field? In this case your query won't work cos your greater and less thans 
are a little bit confused. This query (compare with yours above) should work:

$sql = "SELECT * FROM federal-married WHERE start <= ".$_POST['salary']."
AND end >= ".$_POST['salary'];


Rory McKinley
Nebula Solutions
+27 82 857 2391
rorym@stripped
"There are 10 kinds of people in this world, 
those who understand binary and those who don't" (Unknown)

Thread
Mysql Socket ErrorBirju Shah12 Jan
  • Re: Mysql Socket ErrorDaniel Kasak12 Jan
  • Re: Mysql Socket ErrorBirju Shah13 Jan
  • Re: Mysql Socket Errorwalt13 Jan
    • Using BETWEEN or <= >=Eve Atley13 Jan
      • Re: Using BETWEEN or <= >=Rory McKinley14 Jan
RE: Using BETWEEN or <= >=Mike Johnson13 Jan
Re: Mysql Socket Errorwalt13 Jan
Re: Mysql Socket ErrorDaniel Kasak13 Jan