We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29076
    • 615 Posts
    This is not a MODx questions, and I have asked the question in MySQL forums, but have not yet received a response. Here I have always got answers, so I take the chance to ask the question here too:

    Is it possible in MySQL and retrieve data from a row and put it into another row? I have a field called Name in a MODx table, with data in the form Firstname Lastname. I need to put this into another row as Last Name, First Name, and as Firstname in a separate field and Lastname in another field. Is this possible via SQL?

    That way I avoid having to change the 2000 fields manually.

    Thanks. smiley
      I think, thererfor I am! But what I am, and why...?
      • 4172
      • 5,888 Posts
      you can try:

      update mytable set firstname = substr(fullname,1,LOCATE(' ',fullname)-1),lastname = substr(fullname,LOCATE(' ',fullname)+1) 
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 29076
        • 615 Posts
        Thanks smiley. It works!
          I think, thererfor I am! But what I am, and why...?