List:General Discussion« Previous MessageNext Message »
From:Christian Mack Date:June 18 1999 8:03pm
Subject:Re: MySQL Update Query
View as plain text  
Kevin Smith wrote:
> 
> Hi Everyone,
> 
> I'm new to the list and to MySQL, but have had a good start with it! :-)
> 
> Anyhow, can anyone tell how to create an UPDATE query using two tables.
> For example, how can I write a query similar to this..
> 
> UPDATE BASKET SET BASKET.item=
> (SELECT DISTINCTROW PRODUCTS.item_id
> FROM BASKET, PRODUCTS
> WHERE (((BASKET.id)=(PRODUCTS.id)))
> );
> 
> Or something like that?
> 
> Regards,
> 
> Kevin Smith

Hi Kevin

This will not work.
But you can create a temporary table tmp_BASKET.
Make an INSERT ... SELECT... into the temporary table.
Drop the original table Basket.
Rename the tmp_Basket to Basket.
(this all should be done in a 'write lock' on BASKET)

Tschau
Christian

Thread
MySQL Update QueryKevin Smith18 Jun
Re: MySQL Update QueryChristian Mack19 Jun