Solved

MySQL - Query to edit field based on table join?

Posted on 2013-12-18
1
377 Views
Last Modified: 2013-12-18
Hey,

I have a table of products, each with a "product_id" and a field called "weight".

There is a second table with "product_id" and "category_id".

I need to change the field "weight" to equal "2" for every product that has a  "category_id" of 5, 12, 15, 17 or 18.

Can any one help me build this example please?

Thank you
0
Comment
Question by:mhdi
1 Comment
 
LVL 10

Accepted Solution

by:
acbxyz earned 500 total points
ID: 39728172
This should do it:
update product_table set weight=2
where product_id in (
    select product_id
    from product_category_table
    where category_id in (5, 12, 15, 17, 18)
)

Open in new window

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now