On Thu, 4 Jul 2002 00:18:02 -0700, "Raouf" <aimeur@prodigy.net> wrote:
>table snmpOids
>---------------------------------------------------------------------------------
>id | objectId | objectDescr
>---------------------------------------------------------------------------------
>1 | 1.3.6 | name1
>2 | 1.3.6.1 | name2
>3 | 1.3.6.1.2 | name3
>4 | 1.3.6.1.2.1 | name4
>5 | 1.0.2.3.1 | name5
>6 | 1.1.2.3.1 | name6
>
>type is VARCHAR for all the columns of snmpOids.
>
>Let's say that I have an objectId equal to 1.3.6.1.2.1.1.1 and
>I want to get back from my query the best match on the objectId,
>which is 1.3.6.1.2.1 (closest objectId to 1.3.6.1.2.1.1.1 ).
SELECT *
FROM snmpOids
WHERE '1.3.6.1.2.1.1.1' LIKE objectId || '%'
ORDER BY objectId DESC
LIMIT 1;
should do what you need, but don't tell anybody you got that from me
when it kills your performance ;-)
Servus
Manfred