|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
find a record with field closest to known value
Overview:
This situation arose when I had to display the next event in a table of events based on the current date. Problem: To write a SQL query that will return a single record from a table if and only if a field Y = X' is greater than a known value X AND there are no other records in the table having field Y between X and X'. Thank you in advance for any thoughts, Peter |
|
#2
|
|||
|
|||
|
RE: find a record with field closest to known value
never mind:
SELECT * FROM tablename WHERE fieldY > 'X' ORDER BY fieldY ASC LIMIT 1 |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > find a record with field closest to known value |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|