Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9224413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:18:49+00:00 2026-06-18T04:18:49+00:00

I have 2 tables Table A is as follows: ID NAME VALUE 1 abc

  • 0

I have 2 tables

Table A is as follows:

ID NAME VALUE
1  abc  0
2  lmn  0
3  xyz  0

Table B is as follows:

ID SUB_GROUP   VALUE
1  Category 1  10
1  Category 2  4
1  Category 3  8
1  Category 4  12
3  Category 1  6
3  Category 2  14
3  Category 3  0
3  Category 4  3

I want to UPDATE Table A by setting its VALUE column to the largest VALUE in Table B by matching the ID columns but only for the values in Table B in Category2 or Category 3

What might that MySQL query look like?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:18:51+00:00Added an answer on June 18, 2026 at 4:18 am
    UPDATE  tableA a
            INNER JOIN
            (
                SELECT  ID, MAX(Value) max_val
                FROM    tableB
                WHERE   SUB_GROUP IN ('Category 2','Category 3')
                GROUP   BY ID
            ) b ON a.ID = b.ID
    SET a.VALUE = b.Max_Val
    
    • SQLFiddle Demo
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Table A as follows: ID NAME VALUE 1 abc 10 2
I have two tables as follows PRODUCT table Id | Name | Price And
I'm using PHP/MySql. If I have two tables (hypothetically) as follows: id name and
I have an entity defined as follows @Entity(name = Report) @Table(name = REPORTS) @org.hibernate.annotations.Entity(dynamicInsert
I have a query as follows: String SQL = insert into table (id, name)
i have 2 tables, users and follows. table follows has a column named status.
I have two tables as follows: tblCountry (countryID, countryCode) tblProjectCountry(ProjectID, countryID) The tblCountry table
I have two tables as follows: CREATE TABLE customer ( id INT NOT NULL
I have SQL Server tables as follows: create table TableA ( id int primary
Suppose you have a table as follows: Table Name: CUSTOMER Primary Key: CUSTOMER_ID +-------------+---------------+

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.