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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:44:40+00:00 2026-05-17T02:44:40+00:00

Using MySQL and PHP; I’m trying to build an index that contains the averages

  • 0

Using MySQL and PHP; I’m trying to build an index that contains the averages from table_1 grouped by:

type, name, hour, day, month, year

So I need to know which combination’s of values are in table_1 so I know what to put in my AVG() queries.

What I want is to figure out all the different combination’s that can be made when comparing the following rows in the table:

type
name
hour
day
month
year

Here’s an example of table_1:

ID|type|name|location|amount|year|month|day_num|day|hour|minute|second

1|car|ben|1|1.00|2010|10|01|Friday|03|05|45
1|car|bob|1|3.00|2010|10|01|Friday|04|05|45
2|cow|bob|2|2.00|2009|07|12|Sunday|09|10|12
2|cow|ben|2|4.00|2009|07|12|Sunday|10|10|12

So what I would end up with is:

type|name|year|month|day|hour    

car|ben|2010|10|01|Friday|03
car|bob|2010|10|01|Friday|04
cow|bob|2009|07|12|Sunday|09
cow|ben|2009|07|12|Sunday|10

How would I format a query to do that?

  • 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-17T02:44:40+00:00Added an answer on May 17, 2026 at 2:44 am

    Since you just want the combinations that exist, you can simply run this query:

    SELECT DISTINCT type, name, hour, day, month, year FROM table
    

    This goes through all of the rows, and for each combination that exists in the table, that combination will be output once in the result set.

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

Sidebar

Related Questions

(Using MySQL and PHP) I have a search form that will allow my users
I am using MySQL and PHP to build a data layer for a flash
I am trying to create a table in MySql using php. My code looks
How to fetch the first two rows from Mysql DB using Mysql PHP function?
I'm currently using mysql w/ PHP because that's what I learned and haven't ever
I currently am using mysql and php to display 9 random results from my
I'm trying to develop a system using MySQL and PHP. I'm using mysqli* function
I'm working with long paragraphs of text that are searchable using MySQL and PHP.
We have a web application that has been built using MySQL / PHP /
I'm making a web based project management application using MySQL and PHP that uses

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.