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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:02:53+00:00 2026-05-12T15:02:53+00:00

I have a table that hows the following rows… ID | TITLE | ARTIST

  • 0

I have a table that hows the following rows…

ID     | TITLE   |   ARTIST    |   ADDED               |  HITS | HITS THIS WEEK
--------------------------------------------------------------------------------
7505   | Track 2 |   Artist 1  |   2009-08-24 10:32:41 |  1539 |  2
7483   | Track 2 |   Artist 1  |   2009-08-23 16:58:35 |  1450 |  3
7324   | Track 1 |   Artist 1  |   2009-08-14 11:28:18 |  5291 |  1
7320   | Track 1 |   Artist 1  |   2009-08-14 10:24:17 |  2067 |  1

What I want to do is is have the the duplicates add up the hits and hits this week and display as one row.

I want to fetch the mysql data as it is (with the duplicates), and then using php i wanna sum up the duplicates as one row for echo’ing.

Can someone tell me how I would go about this?

EDIT:

Heres my current sql query…

SELECT `files`.`file_id` , `files_meta`.`title` , `files_meta`.`artists` , `files`.`added` , `files`.`uniquehits` , `files`.`uniquehits_week` , `files_meta`.`filename`
FROM promo_artists
INNER JOIN promo_files ON promo_artists.id = promo_files.artist_id
INNER JOIN files ON files.file_id = promo_files.file_id
INNER JOIN files_meta ON files.file_id = files_meta.file_id
WHERE username = '$username' ORDER BY `files`.`added` DESC
  • 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-12T15:02:54+00:00Added an answer on May 12, 2026 at 3:02 pm

    I’d be inclined to do it in SQL:

    SELECT track, artist, SUM(hits) AS hits, SUM(hits_this_week) AS hits_this_week
      FROM Atable
     GROUP BY track, artist;
    

    This saves having to do the computation in PHP, and reduces the traffic between PHP and the DBMS.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table that I insert data with following query (from c# code): INSERT
I have a table that is something like this: ╔════════════╗ ║ table_test ║ ╠════════════╣
I have a table that displays 10 rows per page. Now, given an item's
I have a table that looks like this: ID |Name |Parent 1 |A |NULL
I Have a table that looks something like this: ComputerID | Free_Space | Disk_Size
i have a table that display a record from the database. Using this php
I have a table that looks like this <table cellpadding=1 cellspacing=0 width=100% border=0> <tr>
I have a table that holds rows representing votes. The fields are an id
I have a table that includes the following column: mytable <- data.frame(beta_0 = c(1,2,3)
I have a table that looks like this: CREATE TABLE [dbo].[StudentTime] ([StudentTimeID] [int] NOT

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.