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

  • Home
  • SEARCH
  • 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 845655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:29:12+00:00 2026-05-15T06:29:12+00:00

i wrote a command like this to update a column in one table with

  • 0

i wrote a command like this to update a column in one table with avg of columns from another table.. its giving errors

UPDATE college_rating,products set 
property1_avg =  avg(college_rating.rating1),
property2_avg =  avg(college_rating.rating2),
property3_avg =  avg(college_rating.rating3),
property4_avg =  avg(college_rating.rating4),
property5_avg =  avg(college_rating.rating5),
property6_avg =  avg(college_rating.rating6),
property7_avg =  avg(college_rating.rating7),
property8_avg =  avg(college_rating.rating8),
property9_avg =  avg(college_rating.rating9),
property10_avg =  avg(college_rating.rating10),
property11_avg =  avg(college_rating.rating11),
property12_avg =  avg(college_rating.rating12),
property13_avg =  avg(college_rating.rating13),
property14_avg =  avg(college_rating.rating14),
property15_avg =  avg(college_rating.rating15) 
where products.alias = concat(college_rating.property1,'-',college_rating.property2,'-',college_rating.property3) 
group by college_rating.property1,college_rating.property2, college_rating.property3
  • 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-05-15T06:29:13+00:00Added an answer on May 15, 2026 at 6:29 am

    The MySQL multi-table update syntax does not allow the use of group by.

    You can accomplish what you are trying to do by moving the aggregation into a sub-query and joining to that sub-query in the multi-table-update instead.

    Something like this should work:

    update products p
    inner join (
      select concat(property1,'-',property2,'-',property3) as alias,
      avg(rating1) as property1_avg,
      avg(rating2) as property2_avg,
      avg(rating3) as property3_avg,
      avg(rating4) as property4_avg,
      avg(rating5) as property5_avg,
      avg(rating6) as property6_avg,
      avg(rating7) as property7_avg,
      avg(rating8) as property8_avg,
      avg(rating9) as property9_avg,
      avg(rating10) as property10_avg,
      avg(rating11) as property11_avg,
      avg(rating12) as property12_avg,
      avg(rating13) as property13_avg,
      avg(rating14) as property14_avg,
      avg(rating15) as property15_avg 
      from college_rating
      group by property1,property2, property3
    ) as r on r.alias = p.alias
    set p.property1_avg = r.property1_avg,
    p.property2_avg = r.property2_avg,
    p.property3_avg = r.property3_avg,
    p.property4_avg = r.property4_avg,
    p.property5_avg = r.property5_avg,
    p.property6_avg = r.property6_avg,
    p.property7_avg = r.property7_avg,
    p.property8_avg = r.property8_avg,
    p.property9_avg = r.property9_avg,
    p.property10_avg = r.property10_avg,
    p.property11_avg = r.property11_avg,
    p.property12_avg = r.property12_avg,
    p.property13_avg = r.property13_avg,
    p.property14_avg = r.property14_avg,
    p.property15_avg = r.property15_avg;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to pass input from node into a commandline-based program I wrote. Starting
I'm running a script on a remote server like using this command: ssh root@host
I would like to write a command line tool that passes some formatted text
I'm trying out the Runtime.exec() method to run a command line process. I wrote
If I have an svn working copy and I'd like to update the working
i know there must be thousands of threads like this, but the internet and
Update : This is an old post, and references below to broken aapt versions
Until recently, I posted Python code (whitespace matters) to blogspot.com using something like this:
i am using PHP to run exec() on a script which looks like this:
For all documents satisfying a given criteria, I would like to patch update a

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.