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

  • Home
  • SEARCH
  • 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

i am using JSP. Now assume I have three tables in mysql related as
using php and mysql I have two tables, a users table and a profiles
I have created a MySQL database using MySQL Workbench. It has about 20 tables.
I have three tables: one indexed by the names of projects (PROJECT) one indexed
I have three MySql tables: Students - StudentId, StudentName Assessments - AssessmentId, AssessmentName Results
(Using MySQL and PHP) I have a search form that will allow my users
I have been using MySQL for 2 years now, yet I still don't know
I have tried fetching MySQL query results using mysql_fetch_row() and mysql_result() and numeric values
I am using in C# MYsql .I have query that works if I run
I'm using MySQL and I currently have a VARCHAR column which stores times (in

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.