Gee, I already mentioned that I solved the problem using the code like the one you have given. And I also mentioned that it would be slow if there are a lot of rows in the table.

As for that, I'm searching for answer on whether the behavior is by design or a bug and if there is another way to solve it.

Thanks.