Hello and welcome to our community! Is this your first visit?
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
    Thanked 79 Times in 79 Posts

    variable into update

    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. #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Thanked 4,947 Times in 4,908 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.

    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.
    Be yourself. No one else is as qualified.


Posting Permissions

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