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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:16:23+00:00 2026-06-04T08:16:23+00:00

I am wanting to create a stored procedure that accepts the team name and

  • 0

I am wanting to create a stored procedure that accepts the team name and year and returns the number of players in that particular team for that particular year. I am working with MYSQL and listed below are the tables I am using:

Person     (personID, name, phone, email, year)
Player     (personID, dateOfBirth, school)
playerTeam (personID, teamID)
Team       (teamID, teamName, ageGroup)

So far I have tried joining the tables and couting the personID only where teamName and Person.year = the input parameters but to no avail. Any ideas?

After submitting this question, using trial and error, I was able to get this to work using the following statements:

DELIMITER //

CREATE PROCEDURE teamSize (IN team VARCHAR (30), IN YEAR INT) 
BEGIN
          SELECT 
                    COUNT(Person.personID) NumOfPlayers 
          FROM
                    Person AS p,
                    Player,
                    playerTeam,
                    Team 
          WHERE Person.personID = Player.personID 
                    AND Player.personID = playerTeam.personID 
                    AND Team.teamID = playerTeam.teamID 
                    AND Team.teamName = team 
                    AND Person.year = YEAR ;
END //

DELIMITER ;

CALL teamSize('Pirates', 1991);

Is there anyway to simplify this using joins etc as at the moment its a bit messy.

  • 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-04T08:16:24+00:00Added an answer on June 4, 2026 at 8:16 am

    I’m not sure if you want like this:

    DELIMITER //
    
    CREATE PROCEDURE GetPlayerCount (
              IN oTeamName VARCHAR (50),
              IN oYear INT
    ) AS 
    BEGIN
              SELECT 
                        COUNT(a.PersonID) NoOfPlayers 
              FROM
                        Person a 
                        INNER JOIN PlayerTeam b 
                                  ON a.PersonID = b.PersonID 
                        INNER JOIN Team c 
                                  ON b.TeamID = c.TeamID 
              WHERE b.TeamName = oTeamName 
                        AND a.Year = oYear ;
    END //
    
    DELIMITER ;
    

    but i think this is want you want.

    Usage:

    CALL GetPlayerCount('TeamDog', 2012);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am wanting to create a query that returns a parent and its guardian
I am wanting to create a VB.Net app that checks a database and then
I was wondering if it is possible in a mysql stored-function or stored-procedure compose
I have a stored procedure that inserts batches of millions of rows, emerging from
I have a stored procedure that needs to convert hexadecimal numbers to their decimal
I'm trying to create a sql update query for a stored procedure but I'm
I have created one stored procedure and its functioning well, what I am wanting
I've been wanting to create a HUD style loading bar like the SMS app
What I am wanting to do is create a PDF ideally from HTML code.
I often find myself wanting to debug CSS layout issues that involve DOM changes

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.