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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:53:33+00:00 2026-06-08T23:53:33+00:00

I have two tables, lists and globals_lists. A globals_lists basically associates a list_id with

  • 0

I have two tables, lists and globals_lists. A globals_lists basically associates a list_id with a global_id value. I’d like to get a count of global_ids (ie the number of ‘manys’ in the globals_lists table) for the associated list type for each user.

something like:

select l.id, l.user_id, count(gl.global_id) as gl_count 
from   lists l, globals_lists gl 
where  l.list_type_id=10 and l.id=gl.list_id;

but this is giving me back wrong information.

  • 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-08T23:53:36+00:00Added an answer on June 8, 2026 at 11:53 pm

    Add:

    GROUP BY l.id, l.user_id 
    

    after your where clause.

    Without GROUP BY, you are basically just counting up all rows that meet the WHERE and join conditions without any regard to set grouping. GROUP BY will ensure that you are performing the count aggregation per user -> list combination.

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

Sidebar

Related Questions

Lets say that I have two tables. The first is: table lists, with list_id
I have two tables names book_list and book_category . Schema is like below: book_list
I have two tables, name and address. I would like to list the last_name
I have two tables in a database, one lists package and one lists dependencies:
I have two tables with lists of files: table1 has column1 with file names
I have two tables 'Elements' and 'Lists' Lists has a primary key and a
I have two database tables that represent lists of items that belong to parent
I have two tables: one table (okay, it's a view), vComputer, lists many computers
I am trying to join two tables like this... SELECT * FROM lists l
I have two tables like the following hotels ------ hotelID hotelName Second table operators

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.