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 9192345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:53:56+00:00 2026-06-17T20:53:56+00:00

First im mysql noob :D Ive tried searching but nothing that can help. Im

  • 0

First im mysql noob 😀
Ive tried searching but nothing that can help.
Im trying to update my database with this query.

UPDATE client SET cntr_limit=(SELECT fulltraffic from 
(SELECT
    client.id,
    (SUM(ipacct.byteso)+SUM(ipacct.bytesi)) as fulltraffic
        FROM client 
            LEFT JOIN ips ON client.id = ips.cid
            LEFT JOIN ipacct ON ips.ip = ipacct.target
            WHERE ipacct.tag = 1
        GROUP BY client.id
     ) as x
) +322122547200 ;

Im getting Subquery returns more than 1 row.
I know the subquery cant have more than one row but i need to work with GROUP BY. If i remove GROUP BY query works but every client get the traffic calculated from all the ips,
instead of traffic calculated differently for every id.

If i use.

 SELECT
    client.id,
    (SUM(ipacct.byteso)+SUM(ipacct.bytesi)) as fulltraffic
        FROM client 
            LEFT JOIN ips ON client.id = ips.cid
            LEFT JOIN ipacct ON ips.ip = ipacct.target
            WHERE ipacct.tag = 1
        GROUP BY client.id;

im getting

id  fulltraffic
1   5100993724986
3   410550845834
4   790726628007
5   204212941099
6   440290245087
8   587044969960

if i remove GROUP BY im getting

id  fulltraffic
1   487196626849368

Thanks in advance.

  • 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-17T20:53:58+00:00Added an answer on June 17, 2026 at 8:53 pm

    use IN instead of =.

    UPDATE client SET cntr_limit IN (SELECT....
    

    and remove the last alias +322122547200 ;

    but a better way to do it is to join the tables on UPDATE statement,

    UPDATE  client a
            INNER JOIN
            (
                SELECT  client.id,
                        (SUM(ipacct.byteso)+SUM(ipacct.bytesi)) as fulltraffic
                FROM    client 
                        LEFT JOIN ips 
                            ON client.id = ips.cid
                        LEFT JOIN ipacct ON ips.ip = ipacct.target
                WHERE   ipacct.tag = 1
                GROUP   BY client.id
            ) b ON a.id = b.id
    SET     a.cntr_limit = b.fulltraffic
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

MySQL noob here; looked around first but couldn't find the answer to this question.
this questions looks really easy but I'm a noob in C++ and MySQL so
First things first ive tried to fix this myself for hours and spent a
I'm trying to create my first mysql stored procedure, but script doesn't work due
I know you can ALTER the column order in MySQL with FIRST and AFTER,
First I wanted to build the DBD::mysql package. That kept failing because whatever make
First off, I'm not an expert with MySQL queries, and I can't seem to
Currently using MySQL version 5.1.6 This is my first real world build and so
I have install the mysql gem but am falling at the first hurdle: initialize':
I'm working in MySQL/PHP. It's a zip code database. The first table has the

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.