0

I'm trying to find an optimized way to move first Character of a Column to end of it, if first Character was '@' , Just when Showing data in DBGrid (Not permanently in database).

There are many Functions in MySQL, but I want to find the best way!

I show many (about 2000) records in DBGrid. Does it affect performance ?!

4
  • In which way you are trying please specify Commented Jan 7, 2014 at 13:24
  • We can't tell that easily. Just try different ways and measure. You should also consider to handle this on application level. Usually this is faster. Commented Jan 7, 2014 at 13:24
  • Did you write any code? Commented Jan 7, 2014 at 13:33
  • Yeah,My Code is like this: SELECT (CASE WHEN ASCII(MyColumn)=64 THEN (CONCAT(SUBSTR(MyColumn,2),'@')) ELSE MyColumn END) FROM MyTable; But I think @fancyPants is right. It is better to handle it in application level ! Commented Jan 7, 2014 at 15:37

2 Answers 2

1

Here is one way to do it. I would not expect it to materially affect performance on 2000 rows:

select concat(substr(your_column,2),left(your_column,1))
from your_table
Sign up to request clarification or add additional context in comments.

Comments

0

Solution:

SELECT (CASE WHEN ASCII(MyColumn)=64 THEN (CONCAT(SUBSTR(MyColumn,2),'@')) ELSE MyColumn END) FROM MyTable;

p.s:64 is ascii code for '@'

But I think @fancyPants is right. It is better to handle it in application level !

I will use OnGetText Event in Dataset to handle it in my application.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.