Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,963
    Thanks
    120
    Thanked 76 Times in 76 Posts

    variable into update

    Code:
    update t
    set f =  UUID()
    where id = 5
    This will give for each record its own UUID
    I want same UUID for each record !

    I know how to do it in two separate sql-s, but I'm almost sure that could be done with one sql only (creating & using varaible inside sql).

    How to do it, if possible ?
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,458
    Thanks
    76
    Thanked 4,373 Times in 4,338 Posts
    Well, I don't know how to do it in one query, but I know how to do it all in a single operation.

    Code:
    SET @u = UUID(); UPDATE t SET f = @u WHERE id = 5;
    As you know, I don't use PHP. That code will work from the MySQL command line or from a MySQL query issued via JSP or ASP or ASP.NET code. But I understand that PHP does not allow multiple MySQL queries per call to mysql_query( ) so I don't know how you would do it with PHP.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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