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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:48:45+00:00 2026-05-27T04:48:45+00:00

I am trying to write a query that can count a joined tables and

  • 0

I am trying to write a query that can count a joined tables and specific column values but I can’t wrap my head around how that would work.

My knowledge is limited to thinking if I want to count all, it would look like this.

"SELECT COUNT(*) FROM 'table'";

So this essentially will return the count of all the rows in that specific table. But I need specific rows in specific tables so how can I do the same count for that?

For example I have this.

SELECT u.ID AS id, u.user_login AS login, u.user_email AS email
   , m_firstname.meta_value AS first_name
FROM users u
LEFT JOIN usermeta m_firstname ON m_firstname.user_id = u.ID
   AND m_firstname.meta_key = 'first_name'

From the above statement how can I count it other than looping it through an array? Is there a MYSQL syntax I can use to resolve this?

*Above example code is just to illustrate what I am trying to do and may not be fully working code.

  • 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-27T04:48:45+00:00Added an answer on May 27, 2026 at 4:48 am

    If you want to count all users, you could use COUNT(1) here. If you want to count the number of NON-NULL values for a specific column, use COUNT(columnName)

    SELECT COUNT(m_firstName.user_id)
    FROM users u
    LEFT JOIN usermeta m_firstname ON m_firstname.user_id = u.ID
       AND m_firstname.meta_key = 'first_name'
    

    The above query will count all records that match this query where m_firstName.user_id is NOT NULL

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

Sidebar

Related Questions

I'm trying to write a query that can select a particular date and count
I am trying to write a query that connects 3 tables. The first table
I'm trying to write a query that will return all QUERY_ID values alongside all
I am trying to write a query for SQL Server 2005 but I can't
I'm trying to write a single Linq Query that can concat inner collections of
I am trying to write an UPDATE query that can check for a null
I am trying to write a query that tracks the history of decimal values
I'm trying to write a query that takes a criterion and returns a count
I'm trying to write a query that will pull back the two most recent
I'm trying to write a query that extracts and transforms data from a 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.