SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist cms9651's Avatar
    Join Date
    Mar 2010
    Posts
    407
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    [MySQL 5.0.45-community-nt-log] Update multiple rows

    Hello my friends, I need your important help.

    I tried this join query:
    Code:
    SELECT
    	A.password,
            A.email,
    	B.email
    FROM
    	tbl_login A
    JOIN tbl_ml B ON A.email = B.email
    WHERE
    	1
    ORDER BY
    	ID DESC;
    In output I have in the column `password` of the tbl_login some rows with NULL value.

    When the field `password` of the tbl_login is NULL value I need update NULL value with alphanumeric string random.

    Can you help me?
    Thanks in advance
    Thanks you very much for your help
    I'm really happy for your quickly answer.
    Good bye

  2. #2
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,089
    Mentioned
    54 Post(s)
    Tagged
    0 Thread(s)
    One login to one "ml" or one login to many "ml"?

  3. #3
    SitePoint Evangelist cms9651's Avatar
    Join Date
    Mar 2010
    Posts
    407
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    thanks for help.

    solved with this sql update query:
    Code:
    UPDATE tbl_login A
    JOIN tbl_ml B ON A.email = B.email
    SET A.password = LOWER(
    	SUBSTRING(
    		(
    			CONV(SUBSTRING(RAND(), 3), 10, 36)
    		),
    		2,
    		8
    	)
    )
    WHERE
    	1
    AND A.password = 'NULL';
    Thanks you very much for your help
    I'm really happy for your quickly answer.
    Good bye

  4. #4
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,706
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is not correct:

    Code:
    AND A.password = 'NULL';
    unless you have the word NULL in the password field. If you mean an actual absence of value NULL then you need
    Code:
    AND A.password IS NULL

  5. #5
    SitePoint Evangelist cms9651's Avatar
    Join Date
    Mar 2010
    Posts
    407
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by guelphdad View Post
    This is not correct:

    Code:
    AND A.password = 'NULL';
    unless you have the word NULL in the password field. If you mean an actual absence of value NULL then you need
    Code:
    AND A.password IS NULL
    You have right my friend... but the rows of the column `password` are not empty or NULL... have a text string with value NULL ... I don't have database administration ...
    Thanks you very much for your help
    I'm really happy for your quickly answer.
    Good bye

  6. #6
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,706
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cms9651 View Post
    You have right my friend... but the rows of the column `password` are not empty or NULL... have a text string with value NULL ... I don't have database administration ...
    That's not what you said in your initial post though.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •