By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,962 Members | 1,997 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,962 IT Pros & Developers. It's quick & easy.

Move some part of data from one column to another

P: 3
I have a column (StudentName) in my database table which has the students full name (both Surname and FirstName). But it is arranged such that the surname comes first.

Now, my problem is I want to move only the surname to a different column called 'Surname'.

How do I do it such that it will start selecting from the first character and stops once it meets the space, and then use it to update the 'Surname' column?

Thank you for your cooperation.


Becks.
Jan 20 '15 #1

✓ answered by Luuk

Expand|Select|Wrap|Line Numbers
  1. SELECT substr(StudentName, 1, LOCATE(' ',StudentName)-1) AS Surname.......
see: this for more info

Share this Question
Share on Google+
2 Replies


Expert 100+
P: 1,031
Expand|Select|Wrap|Line Numbers
  1. SELECT substr(StudentName, 1, LOCATE(' ',StudentName)-1) AS Surname.......
see: this for more info
Jan 21 '15 #2

P: 3
Hi Luuk,

Thanks so much.

The code has work perfectly.

Good Job done.
Jan 23 '15 #3

Post your reply

Sign in to post your reply or Sign up for a free account.