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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:43:16+00:00 2026-05-26T21:43:16+00:00

My users submit information for locations. I’m trying to write a query that will

  • 0

My users submit information for locations. I’m trying to write a query that will tell me the number of submits they’ve done for each location along with that location’s name.

This query seems to be a start in the right direction. It returns the id for each location that the user has submitted information.

SELECT reports.location_id
FROM reports
WHERE reports.user_id =104
ORDER BY reports.locations_id

An example of the return from this query is:

locations_id
99
99
99
112
115
115

For my final html output; however, I would like to show something more along the lines of this:

   location_name  number_of_submits
    name_1        3
    name_2        1
    name_3        2

Is there a mysql query I could use to get this? Or would I need to use php to iterate through my query’s results (i.e. recognize 99 was returned 3 times and fetch 99’s name from the locations table, then recognize 112 was returned once and fetch its name, and so on).

Thank you…

  • 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-26T21:43:17+00:00Added an answer on May 26, 2026 at 9:43 pm

    Use GROUP BY / COUNT:

    SELECT
        location_name,
        COUNT(*) AS number_of_submits
    FROM reports
    JOIN markers ON markers.id = reports.location_id
    WHERE reports.user_id = 104
    GROUP BY reports.location_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a project where I will let users submit small 'scripts'
I use a php form processor script that works fine. Except when users submit
I'm creating a site that allows users to submit quotes. How would I go
Am currently working on an application that requires users to submit posts and comments
I am learning RoR and trying to use accepts_nested_attributes_for and has_and_belongs_to_many to submit information
I am trying to setup a system where users can submit an equation to
In my rails app I'd like to let users submit custom themes to display
I'm writing a web application where users can submit pictures, videos, and descriptons of
I'm currently working on a ticketing system which allows our users to submit tickets
I have a scenario where users of my ASP.NET web application submit testimonials consisting

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.