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
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'];
+27 82 857 2391
"There are 10 kinds of people in this world,
those who understand binary and those who don't" (Unknown)