1

Following in my sql fiddle: http://sqlfiddle.com/#!2/62429/2

I have a username , which i need to split between first name and last name . One logic I have in mind is to get last name as per father name means if Nick samuel is username and samuel james is father's name as samuel is in fathers name so it becomes last name for user and remaining becomes first name for user. Kindly let me know how can i implement this logic in my fiddle. Moreover, lets say if there is not match between father name and username then as per our predefined ratio (count of username string spearated by " " so for name nick jhon count is 2 and its divied by 2 which gives 1, so for that computed value we'll make first name the first part of the string i.e jhon and rest become last name and for names like jammie james jonathan bing then its count being divided by 2 and gives 2 so in this case first two strings are become first name and remaining becomes last name) . I was confused in implementing both logics so i asked for help. Thanks

Naqash Malik
  • 1,707
  • 1
  • 12
  • 14
  • I think this question will help you with this: http://stackoverflow.com/questions/471914/can-you-split-explode-a-field-in-a-mysql-query –  Dec 12 '12 at 12:25
  • there is no logic behind your question its insane to decide based on the fathers name and username have a column called first_name and last_name in your table. – yednamus Dec 12 '12 at 12:31

1 Answers1

1

I solved it here

http://www.sqlfiddle.com/#!2/b6f85/6.

It returns you last word of your Username as last name and rest of the Username would become firstname of it..

Chella
  • 1,561
  • 4
  • 23
  • 42