[Asterisk-Users] Re: OT : For the SQL gurus..
Thorsten Lockert
tholo at sigmasoft.com
Mon Nov 10 08:34:06 MST 2003
SELECT *, LENGTH(code)
FROM a
WHERE code = left('00442085673456', LENGTH(code))
ORDER BY LENGTH(code) DESC
LIMIT 1;
-----Original Message-----
From: asterisk-users-admin at lists.digium.com
[mailto:asterisk-users-admin at lists.digium.com] On Behalf Of WipeOut
Sent: Monday, November 10, 2003 9:33
To: asterisk-users at lists.digium.com
Subject: Re: [Asterisk-Users] Re: OT : For the SQL gurus..
Reinhard Max wrote:
>On Mon, 10 Nov 2003 at 13:34, WipeOut wrote:
>
>
>
>>I guess I am going to have to look through the table multiple times
>>dropping the last digit on each select until I get a result..
>>
>>
>
>You could also try this one to see which one is faster:
>
> SELECT *, length(code)
> FROM a
> WHERE code = '00442085673456'
> OR code = '0044208567345'
> OR code = '004420856734'
> OR code = '00442085673'
> OR code = '0044208567'
> OR code = '004420856'
> OR code = '00442085'
> OR code = '0044208'
> OR code = '004420'
> OR code = '00442'
> OR code = '0044'
> ORDER BY length(code) DESC;
>
>Again, the first row in the result set is the one you are after.
>
>
>cu
> Reinhard
>
>
>
That works quite well.. result in 0.11 seconds..
I just have to work out now how to create the query in my code.. :)
Thanks a lot..
_______________________________________________
Asterisk-Users mailing list
Asterisk-Users at lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-users
More information about the asterisk-users
mailing list