>>I'm not even talking about the original code. I'm talking about the general principle here.
>
>I just answer on this question:
>
>>how it will be done in sql
>
>and my code try to do same as original code.
Ok, are you interested in solving the problem in general?
If it's not broken, fix it until it is.
My Blog