Update one table field from another table field query?
am 27.07.2006 01:15:28 von MattMika
I recently changed the field length for products_model in our products
table from varchar(12) to varchar(15) and failed to update that field
in our orders_products table. So now I have incomplete model #'s in
our orders_products table.
I am unsure how to go about doing this in a query. Maybe something
like this?:
UPDATE orders_products SET products_model = (SELECT products_model
from products)
WHERE products.products_id = orders_products.products_id;
Any suggestions would be greatly appreciated.
TIA
Matt Mika
Re: Update one table field from another table field query?
am 27.07.2006 19:17:17 von MattMika
On Wed, 26 Jul 2006 17:15:28 -0600, MattMika
wrote:
>I recently changed the field length for products_model in our products
>table from varchar(12) to varchar(15) and failed to update that field
>in our orders_products table. So now I have incomplete model #'s in
>our orders_products table.
>
>I am unsure how to go about doing this in a query. Maybe something
>like this?:
>
>UPDATE orders_products SET products_model = (SELECT products_model
>from products)
>WHERE products.products_id = orders_products.products_id;
>
>Any suggestions would be greatly appreciated.
>TIA
>Matt Mika
I copied my tables and tested. Changed the above to:
UPDATE orders_products SET products_model = (SELECT products_model
from products WHERE products.products_id =
orders_products.products_id);
Worked like a charm...
Matt Mika