× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Someone was asking a question on a python board that I subscribe to.

He has a table in a MySQL database which contains a VarChar which
represents a Confirmation Number.

It may be NULL.
And I assume it may contain invalid numerics.

He wants to be able to (for example) retrieve the last 10 Confirmation
Numbers based on a numerical sort sequence.

Obviously he can't order by the existing VarChar Confirmation Number
because it's alpha and he will get results like:
901
900
90
899
898

So he has been using CAST to convert the NOT NULL values to INT and then
sorting on that but his response time for the query is very slow due to the
volume of data (and also I think it's part of a larger query)

I don't think views will help his cause as you can't use ORDER BY.

My first thought was - can he add another column to the table (over which
he could add a non-unique index) - make it NOT NULLABLE and default to 0.
Then in the application, modify it when a valid numeric value is entered in
the Confirmation Numer column.

If it's not viable to modify the application - would it make sense to use
an UPDATE TRIGGER to keep the new column maintained.

I don't actually recall having modified the after image in a trigger
program - is that a reasonable thing to do?

Any advice/comments gratefully accepted.
thanks,
Craig

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.