Does anyone know how I can replace a number, in this case a year, to make it partially random? For instance I want a whole range of numbers within the 1980s and currently have every row showing 1980, so need somthing like UPDATE tablename SET tablefield = replace(tablefield,"1980","198*rnd"); Code (markup): Only I don't know how to work the *rnd bit to make the figure after 198?
UPDATE tablename SET tablefield = replace(tablefield,'1980',CONCAT('198', FLOOR(RAND()*10))); Code (markup):
Thanks, that's brilliant! I wasn't even sure it was possible, database stuff blows me away sometimes, which makes me feel such a geek. I would give you a +rep but it wont let me because I just gave you a +rep recently. I started a little PHP help site of my own recently that's more for my own reference than anything else, and decided to put a MySQL snippet I learned last night on there because I keep learning stuff then forgetting where I saw it. Anyway I just put the code with your correction on just now: http://www.phpecho.com/mysql-tutorials/updatemysqlfieldrandomnumber.html - so I have two snippets so far.