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?
> Kevin Smith
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)