Hi Dan,

Thanks for the prompt reply,

As I described it yes, you are correct, however, the id may not always be one(1) value away. So the number one needs, somehow, to be replaced with a way to get the "next largest value " and the "previous less than" value.

Sorry for the lack of precision in my prior post.

Regards,
Michael


Dan Julson wrote:

Michael,

I would think this is what you want.

Select ID from T1 where ID BETWEEN (<id in question> - 1) and (<id in question> + 1) If you want distinct values, place the distinct keyword in front of ID (i.e. Select DISTINCT ID...

This should do it for you.
-Dan

Hi,

Does anyone have a clever way of returning; a requested value with  one
value  less than that value, and one value greater than that value with
one query.

For example T1 contains

ID
1234
1235
1236
1238

select ID from T1 where ID = 1235 and ID<1235 and ID >1235 LIMIT 3
(obviously this doesn't work)  I would want to return....

1234
1235
1236

or;
select ID from T1 where ID = 1237 and ID<1237 and ID >1237 LIMIT 3 I
would want

1236
1238

I would be surprised if there was no way of doing this.....but then
again, I'm often surprised....

Thanks
Michael

--
Michael DePhillips
www.star.bnl.gov



--
Michael DePhillips
www.star.bnl.gov


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to