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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:18:22+00:00 2026-05-22T12:18:22+00:00

This table contains 1.2mill results, and I can’t edit it as there are applications

  • 0

This table contains 1.2mill results, and I can’t edit it as there are applications which I don’t have the source code to accessing it as well. I’d like to add a quantity field, but I can’t.

Here is a query I am using:

  SELECT SUM(assets.hourlyEarnings) as earnings, 
         assets_inventory.uid
    FROM (assets)
    JOIN assets_inventory ON assets.id = assets_inventory.assetID
   WHERE assets_inventory.uid IN (SELECT users.uid 
                                    FROM users 
                                   WHERE users.assetTime < 1305350756)
GROUP BY uid

There are many duplicate records.

Here is the table:

CREATE TABLE IF NOT EXISTS assets_inventory (
  id int(11) NOT NULL AUTO_INCREMENT,
  uid bigint(20) NOT NULL,
  assetID int(11) NOT NULL,
  PRIMARY KEY (id),
  KEY uid (uid)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1231992 ;

On average I’m taking 6-7 seconds to pull the results, any suggestion to speed this up would be appreciated!

  • 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-22T12:18:23+00:00Added an answer on May 22, 2026 at 12:18 pm

    If you want a list of all uid values, whether or not there are earnings associated:

       SELECT DISTINCT
              ai.uid,
              COALESCE(x.earnings, 0) AS earnings
         FROM ASSETS_INVENTORY ai
    LEFT JOIN (SELECT t.id,
                      SUM(t.hourlyearnings) AS earnings
                 FROM ASSETS t
             GROUP BY t.id) x ON x.id = ai.assetid
        WHERE EXISTS (SELECT NULL
                        FROM USERS u
                       WHERE u.uid = ai.uid
                         AND u.assettime < 1305350756)
    

    Otherwise:

      SELECT ai.uid,
             SUM(a.hourlyearnings) AS earnings
        FROM ASSETS_INVENTORY ai
        JOIN ASSETS a ON a.id = ai.assetid
       WHERE EXISTS (SELECT NULL
                       FROM USERS u
                      WHERE u.uid = ai.uid
                        AND u.assettime < 1305350756)
    GROUP BY ai.uid
    

    …or:

      SELECT ai.uid,
             SUM(a.hourlyearnings) AS earnings
        FROM ASSETS_INVENTORY ai
        JOIN ASSETS a ON a.id = ai.assetid
        JOIN USERS u ON u.uid = ai.uid
                    AND u.assettime < 1305350756
    GROUP BY ai.uid
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings, fellow coders! I have this table that contains categories and subcategories (actually I
enter code here My problem is this: in this database the junction table contains
I have a table called 'friends', this contains the columns person1 and person2 .
I have this database which contains a varchar. I want to know which records
I have this table that contains the ad id and the user id. Any
I have a table that contains lots of integers. This table gets queried and
I have a MySQL MyISAM table containing entries that describe airports. This table contains
I have a simple table in my SQL Server database. This table contains two
I have a table called orders this table contains all the information we need.
I have a table for a contact form and this table contains another table

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.