Jump to content

Changing the position of first name to the last name, and vise versa


radit91

Recommended Posts

SELECT SUBSTRING ( Name, CHARINDEX ( ' ', Name ) + 1, LEN ( Name ) ) + ', ' + SUBSTRING ( Name, 1, CHARINDEX ( ' ', Name ) ) as 'Name'

Hai guys. The code is about putting the last name to the front, the last name to the back, and put coma(,) in the middle. But, the code was to complicated for me. Can you please explaine it to me or maybe give other code that is much simpler and if you could with some explanation. I'm new to the SQL. Thankyou.

Link to comment
Share on other sites

Depending on which database you're using, check the reference for the string functions for that database to see what each of those functions (substring, charindex, len, etc) does. This is the string function reference for MySQL, for example: http://dev.mysql.com/doc/refman/5.0/en/string-functions.html

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...