>>>>> "Iain" == Iain Tatch <[EMAIL PROTECTED]> writes:
Iain> On Sunday, August 17, 2003, 10:01:51 AM, Peter Sergeant wrote: PS> It's at times like this I realise my SQL skills only cover the basics... PS> I have two tables, 'user' and 'users_names'. I'm looking to deprecate PS> 'users_names', so I've altered 'user' to now contain a 'user_realname' PS> column. Both tables have a column 'user_id', which correspond to each PS> other. I'd like to take the data from 'users_names.name' and put it into PS> 'user.user_realname' where the 'user_id' column match. I just can't seem PS> to find the SQL to make MySQL do this. Iain> is it not simply: Iain> UPDATE user Iain> SET user.user_realname = user_names.name Iain> WHERE user.user_id = user_names.user_id To do it in standard SQL, you need a subselect. UPDATE user SET user_realname = (SELECT name FROM user_names WHERE user.user_id = user_names.user_id); If your db doesn't offer subselects, you've got to create a temp table. (And people who use MySQL wonder what the value of subselects are! :) -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!