* USER
> Is there any way to do an Update...Select like an Insert....Select?
>
> For instance can I fill one table with data from another table.
> The columns
> do not match exactly so a table copy won't do much good.  But the data
> retrieved in the select command is compatible with the new table fields.

Use INSERT ... SELECT.

What you describe is not an update, it is an insert. The columns of the new
table does not have to match with the exising table, you just need to
formulate the select so that the correct fields are selected in the correct
order:

insert into whatever
  select f1, mid(f2,5,3) as f2, year(f3) as f3 from someother;

You can even use joins:

insert into whatever
  select f1, mid(f2,5,3) as f2, year(another.f3) as f3
  from someother, another
  where another.id = someother.something;

--
Roger
query


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to