Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Separate a column value into 2 column in MySQL table

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 253
    Comment on it

    Hello friends,

    I am here to share a issue which I faced once, That is I want to separate a columns values into 2 columns.
    So if you are also looking to separate a columns value into 2 columns, You can use following syntax-

    UPDATE your_table SET column1 = SUBSTRING_INDEX(your_table.column1,'(', 1),  column2 = SUBSTRING_INDEX(your_able.column1,'(', -1);
    

    For example, you have a table 'user' and a column 'firstname' with the value 'firstname lastname'. Here ' ' (space) is used as separator. Now you have to separate the firstname and lastname into 2 separate columns. You can use following query-

    UPDATE user SET firstname = SUBSTRING_INDEX(user.firstname,'(', 1),  lastname = SUBSTRING_INDEX(user.firstname,'(', -1);
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: