Re: [PHP-DB] Checking if number is in bottom three?

2002-12-23 Thread Doug Thompson
Generally, you want to use the LIMIT function.

SELECT num FROM myfile ORDER BY num LIMIT 3;

However, if the values may be repeated (e.g., 1,1,1,2,4,4,5), the query
above will return 1,1,1.
If you are interested in the three lowest values and not just smallest
entries, add DISTINCT

SELECT DISTINCT num FROM myfile ORDER BY num LIMIT 3;
  which will return 1,2,4

I hope this answers your question.

Merry Christmas,
Doug



On Mon, 23 Dec 2002 11:13:31 -0500, Leif K-Brooks wrote:

>I need a way to check if a number is in the bottom three of a column in 
>my database.  For example, if I had a list of number in my table like this:
>1
>5
>8
>12
>60
>1
>10001
>I might need to know if 5 was in the bottom three, which it would be. 
> But if I checked 60, it wouldn't be.  I could check the lowest number 
>and add 3 to it, but it may have gaps.  Any ideas?
>
>-- 
>The above message is encrypted with double rot13 encoding.  Any unauthorized attempt 
>to decrypt it will be prosecuted to the full extent of the law.
>
>
>
>-- 
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Checking if number is in bottom three?

2002-12-23 Thread Leif K-Brooks
Thanks, but what I want to do is check if a number is in the first 3, 
not return the first three.  If returning the first three and seeing if 
any of them matches is the only way, I'll do that, but it doesn't seem 
that great for the server.

SELPH,JASON (HP-Richardson,ex1) wrote:

select myfield from table order by myfield DESC limit 3

That will return the last 3 records in your database where the highest
number is the last.  Think of it as sorting by that number in reverse and
only returning the first 3.

Cheers
Jason

-Original Message-
From: Leif K-Brooks [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 23, 2002 10:14 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Checking if number is in bottom three?


I need a way to check if a number is in the bottom three of a column in 
my database.  For example, if I had a list of number in my table like this:
1
5
8
12
60
1
10001
I might need to know if 5 was in the bottom three, which it would be. 
But if I checked 60, it wouldn't be.  I could check the lowest number 
and add 3 to it, but it may have gaps.  Any ideas?

 


--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Checking if number is in bottom three?

2002-12-23 Thread Leif K-Brooks
I need a way to check if a number is in the bottom three of a column in 
my database.  For example, if I had a list of number in my table like this:
1
5
8
12
60
1
10001
I might need to know if 5 was in the bottom three, which it would be. 
But if I checked 60, it wouldn't be.  I could check the lowest number 
and add 3 to it, but it may have gaps.  Any ideas?

--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php