Just want to have first name only

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • samuel123
    New Member
    • Nov 2007
    • 7

    Just want to have first name only

    Greetings All,
    Once again back to this forum.

    I have got a problem and hope to get solution.

    Senario..
    I have a table called users, it has following fields
    user_name firstname lastname
    ---------------- -------------- -------------
    Parker Alan & Jenny Parker


    I have exported data to user table and my user data is in user_name field
    and first name field is blank

    Want to Achieve: Parker Alan & Jenny which is in user_name field and I want to achieve only first name as Parker in firstname field using some update command(Just shown above )

    How can I achieve this?
    Your help would be greately appreciated
    Samuel
  • samuel123
    New Member
    • Nov 2007
    • 7

    #2
    Just found a little way..

    Did this way

    update users set firstname=subst r(user_name,1,7 )

    Above query got nearly correct result

    Pearson
    Allie

    Some are like this
    Bobsol L

    Now my question in Bobsol L Now I want to remove white space and L charcter

    Thanks

    Comment

    • amitpatel66
      Recognized Expert Top Contributor
      • Mar 2007
      • 2358

      #3
      Originally posted by samuel123
      Just found a little way..

      Did this way

      update users set firstname=subst r(user_name,1,7 )

      Above query got nearly correct result

      Pearson
      Allie

      Some are like this
      Bobsol L

      Now my question in Bobsol L Now I want to remove white space and L charcter

      Thanks
      Try This:

      [code=mysql]

      update users set firstname=subst r(user_name,1,I NSTR(first_name ,' ')-1);

      [/code]

      Comment

      • samuel123
        New Member
        • Nov 2007
        • 7

        #4
        Hi,
        Thank you so much for your response. That has helped me.


        Once again thank you for your kind help
        Samuel

        Comment

        • amitpatel66
          Recognized Expert Top Contributor
          • Mar 2007
          • 2358

          #5
          Originally posted by samuel123
          Hi,
          Thank you so much for your response. That has helped me.


          Once again thank you for your kind help
          Samuel
          You are Welcome :)

          Do post back in case of any issues.

          Amit

          Comment

          Working...