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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:58:24+00:00 2026-06-18T00:58:24+00:00

ticket +———-+——–+ | ticketID | assign | +———-+——–+ | 1015 | NULL | |

  • 0
ticket                      
+----------+--------+
| ticketID | assign |
+----------+--------+
|     1015 | NULL   |
|     1020 | James  |
|     1021 | Nick   |
+----------+--------+

staffinfo
+---------+-------+
| staffID | staff |
+---------+-------+
|       1 | Jane  |
|       2 | James |
|       3 | Nick  |
|       4 | Cole  |
+---------+-------+

SELECT staff,COUNT(*) as count FROM staffinfo,ticket
WHERE ticket.assign = staffinfo.staff
GROUP BY staff

result:
    +-------+-------+
    | staff | count |
    +-------+-------+
    | James |     1 |
    | Nick  |     1 |
    +-------+-------+

Works fine, but infact i need smthing like:

+-------+-------+
| staff | count |
+-------+-------+
| James |     1 |
| Nick  |     1 |
| Jane  |     0 |
| Cole  |     0 |
+-------+-------+

COUNT doesnt count records that arent in the table, and since i just started learning SQL, i wanna ask if theres a way to count as the above result?

  • 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-18T00:58:24+00:00Added an answer on June 18, 2026 at 12:58 am

    you should be using LEFT JOIN

    SELECT  a.staff,    COUNT(b.assign) as count 
    FROM    staffinfo a
            LEFT JOIN ticket b
                ON b.assign = a.staff
    GROUP   BY a.staff
    
    • SQLFiddle Demo

    To fully gain knowledge about joins, kindly visit the link below:

    • Visual Representation of SQL Joins
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public class Ticket { public bool Selected { get; set; } public string TicketID
I have the following table: ticket arrivaltime resolution time status t1 '2012-09-03' null new
I have 2 following tables : Ticket(ID, Problem, Status,Priority, LoggedTime,CustomerID*, ProductID*); TicketUpdate(ID,Message, UpdateTime,TickedID*,StaffID*); Here
I'm designing a ticket system in PHP/MySQL. Each ticket represents one row in the
I've got a Ticket model that I'm trying to search by its IntegerField priority
I have a simple ticket logging application build on LAMP. I am currently playing
I have a Ticket class that contains a List of User objects: class Ticket
I have a Ticket model which has_many :tags . I would like to find
I am working on a mobile ticket sales app. The system allows users to
I am trying to create a ticket for Remote Assistance. Part of that requires

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.