CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   MySQL (http://www.codingforums.com/forumdisplay.php?f=7)
-   -   variable into update (http://www.codingforums.com/showthread.php?t=284398)

BubikolRamios 12-19-2012 12:02 PM

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 ?

Old Pedant 12-19-2012 07:52 PM

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.


All times are GMT +1. The time now is 05:58 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.