Forgot how to do a mass update in mySQL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Wm

    Forgot how to do a mass update in mySQL

    I can't remember if I did this last time in phpMyAdmin or if I did it some
    other way... I have 2 new fields in a database that I need to fill with
    values. One field needs to have the default "0" updated to "1" in every
    field. The other one I want to insert a randomly generated password. The
    password function is in a form for all subsequent record insertions, but I
    want to populate the existing 1100 records with one also. What's the
    easiest way to fill these 2 fields without wiping out my data?

    Thanx,
    Wm



  • Wm

    #2
    Re: Forgot how to do a mass update in mySQL

    That solved both problems -- THANX!

    Wm

    "Tom Thackrey" <tomnr@creati ve-light.com> wrote in message
    news:mCkZa.588$ iT.29742271@new ssvr13.news.pro digy.com...[color=blue]
    >
    >
    > On 9-Aug-2003, "Wm" <LAshooter@hotm ail.com> wrote:
    >[color=green]
    > > I can't remember if I did this last time in phpMyAdmin or if I did it[/color][/color]
    some[color=blue][color=green]
    > > other way... I have 2 new fields in a database that I need to fill with
    > > values. One field needs to have the default "0" updated to "1" in every
    > > field. The other one I want to insert a randomly generated password. The
    > > password function is in a form for all subsequent record insertions, but[/color][/color]
    I[color=blue][color=green]
    > > want to populate the existing 1100 records with one also. What's the
    > > easiest way to fill these 2 fields without wiping out my data?[/color]
    >
    > 1- update mytable set newfield=1
    > or
    > 1a- update mytable set newfield=1 where newfield=0
    > 2- update mytable set passwd=RIGHT(PA SSWORD(RAND()), 8)
    >
    > FYI the use of PASSWORD in no. 2 is coincidental to its being a password
    > field, also you can adjust the length of the password by changing the 8 to
    > whatever you like.
    > --
    > Tom Thackrey
    > www.creative-light.com[/color]


    Comment

    • Gary Petersen

      #3
      Re: Forgot how to do a mass update in mySQL

      On Sun, 10 Aug 2003 13:18:32 -0500, in message
      <Y%vZa.1646590$ Ho4.11633963@ne ws.easynews.com >,"Wm"
      <LAshooter@hotm ail.com> wrote:
      [color=blue]
      > "Tom Thackrey" <tomnr@creati ve-light.com> wrote in message
      > news:mCkZa.588$ iT.29742271@new ssvr13.news.pro digy.com...[color=green]
      >>
      >> [...]
      >> 1- update mytable set newfield=1
      >> or
      >> 1a- update mytable set newfield=1 where newfield=0 2- update mytable
      >> set passwd=RIGHT(PA SSWORD(RAND()), 8)[/color]
      >
      > That solved both problems -- THANX!
      >[/color]

      And it was very educational for me. Thanks.

      Comment

      • Tom Thackrey

        #4
        Re: Forgot how to do a mass update in mySQL


        On 12-Aug-2003, "Wm" <LAshooter@hotm ail.com> wrote:
        [color=blue]
        > OK, now that the initial update is done, is there any way to format the
        > data
        > that is already in mySQL? In phpMyAdmin, I've tried various combinations
        > like:
        > update backup set email=STRTOLOWE R(email)
        > or
        > update backup set email=STRTOLOWE R('email')
        > with obviously no success. I know that this is a PHP command, but is there
        > any way to apply formatting to the data already in mySQL?[/color]

        update backup set email=lower(ema il)

        you might find the MySQL manual useful in restoring your fading memory ;->



        --
        Tom Thackrey

        Comment

        Working...