Jump to content

[SOLVED] I am trying to insert random MD5 into multiple rows at a time..


sedolan

Recommended Posts

Server version: 5.0.58-log

MySQL client version: 4.1.22

 

UPDATE `gameadds_maxadds`.`users` SET `remove` = MD5(uniqid(rand(), true)) WHERE `users`.`id` =*; 

 

Error

 

SQL query:

 

UPDATE `gameadds_maxadds`.`users` SET `remove` = MD5( uniqid(

rand( ) , true )

)

 

MySQL said: Documentation

#1305 - FUNCTION gameadds_maxadds.uniqid does not exist

 

 	CREATE TABLE `users` (
`id` int(11) NOT NULL auto_increment,
`email` varchar(255) NOT NULL,
`active` varchar(32) NOT NULL,
`game` varchar(255) NOT NULL,
`remove` varchar(32) NOT NULL,
PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=516 DEFAULT CHARSET=latin1

 

 

So basically all I am trying to do is replace all the data that's in the remove column with new unique random md5 data, since this option was implemented later on in our coding progress I have multiple rows that currently have no md5 data in the remove field.

 

Thanks in advance,

-Sean

Link to comment
Share on other sites

You appear to be attempting to use uniqid as a MySQL function, I've searched the documentation and no such function seems to exist (though I've never liked their documentation), it would appear that MySQL has assumed it is a column name in your table.

Link to comment
Share on other sites

UPDATE `gameadds_maxadds`.`users` SET `remove` = MD5(uniqid(rand(), true)) WHERE `users`.`id` =*; 

 

Those are all PHP functions, so I'm guessing thats what you meant to do - one unique for the whole set?

$sql = "UPDATE `gameadds_maxadds`.`users` SET `remove` = '".MD5(uniqid(rand(), true))."' WHERE `users`.`id` =*";

 

If you want to do it purely mysql, and generate a random result each time:

UPDATE `gameadds_maxadds`.`users` SET `remove` = MD5(RAND()) WHERE `users`.`id` =*; 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.