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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:30:39+00:00 2026-05-14T05:30:39+00:00

Using MySQL, I have three tables: projects : ID name 1 birthday party 2

  • 0

Using MySQL, I have three tables:

projects:

ID  name
1   "birthday party"
2   "soccer match"
3   "wine tasting evening"
4   "dig out garden"
5   "mountainbiking"
6   "making music"

batches:

ID  projectID  templateID  when
1   1          1            7 days before
2   1          1            1 day  before
3   4          2           21 days before
4   4          1            7 days before
5   5          1            7 days before
6   3          5            7 days before
7   3          3           14 days before
8   5          1           14 days before

templates:

ID  name  message
1   inf1  "Hi, I'd like to invite ..."
2   for1  "Dear Sir, Madam, ..."
3   can1  "Can you please ..."
4   inf2  "Would you like to ..."
5   all1  "To all dear friends ..."
6   inf3  "Does any of you guys ..."

I would like to display a table of templates and the number of projects they’re used in.
So, the result should be (updated!):

templateName  projectCount
inf1          3
for1          1
can1          1
inf2          0
all1          1
inf3          0

I’ve tried all kinds of SQL queries using various JOINs, but I guess this is too complicated for me. Is it possible to get this result using a single SQL statement?

  • 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-14T05:30:39+00:00Added an answer on May 14, 2026 at 5:30 am
    SELECT t.name templateName, COUNT(DISTICT b.projectID) projectCount
    FROM templates t
    LEFT OUTER JOIN batches b ON t.ID = b.templateID
    GROUP BY t.ID, t.name
    ORDER BY t.ID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Note: Using MySQL 4.0, which means no subqueries (at present). I have 2 tables:
I am using MySQL and PHP for a project I am working. I have
I have been using the MySql Query Browser and [opinion]it has to be the
I have been using the mysql api in PHP, and am now converting to
I am using the MySQL C API within a C++ application. I have a
I have a dataset in MySQL where using limit is already an expensive query,
Using PHP and MySQL, I have a forum system I'm trying to build. What
I have a web site using apache httpd as the server and mysql as
I am using ruby on rails with a MySQL backend. I have a table
I have a mySQL database that tracks our projects and drives our website's display

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.