We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28042 ☆ A M B ☆
    • 24,524 Posts
    So if I want to replace all the usernames with their respective email addresses, there's a way to write a query to do it all in one go, right?

    something like "update web_users set web_users.username = web_user_attributes.email where web_user_attributes.internalKey = web_users.id"

    Makes my head hurt.

      Studying MODX in the desert - http://sottwell.com
      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
      Join the Slack Community - http://modx.org
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Got it! (Google is my friend)

      UPDATE modx_web_users wu
      SET username =
      (SELECT email
      FROM modx_web_user_attributes wua
      WHERE wua.internalKey = wu.id)


      More along the lines of what I was thinking originally, this also works:

      UPDATE modx_web_users wu, modx_web_user_attributes wua
          SET wu.username = wua.email
          WHERE wu.id = wua.internalKey
      [ed. note: sottwell last edited this post 14 years, 1 month ago.]
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org