0

Is there any syntax query in mysql phpmyadmin to trim alphanumeric(varchar) data? Here's how I want it to happen:

In my table i have two fields id(int) and promocode(varchar)(25), inside my promocode column I have this sample data BEFKR679GKQTX46AFKP14VY composed of (25) ...and i want it to trim the first 12 alphanumeric only, making it look like these BEFKR679GKQT.. and I don't know how to change the existing 1,000 inputted data in my table.. into all 12 not 25.

1 Answer 1

1
  1. Back up your tables. If you can't do this, don't continue.

  2. Test a command like on a test table and make sure you understand it:

    UPDATE my_table SET promocode = SUBSTRING(promocode,1,12);
    
  3. When it works you your satisfaction on test tables, and your back up is complete, do it to the real table.

More info on MySQL string functions is here:

http://dev.mysql.com/doc/refman/5.0/en/string-functions.html

Running SQL from phpMyAdmin is here:

http://community.mybb.com/thread-4720.html

Sign up to request clarification or add additional context in comments.

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.