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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:19:40+00:00 2026-05-24T00:19:40+00:00

So here I am and need to see some results from a MYSQL database

  • 0

So here I am and need to see some results from a MYSQL database based not on one but on results from a few tables.

TABLE DESCRIPTION:

Metaexplanation:

Tablename

Row1,Row2,Row3....Row(N)

Tables:

---------------
|table toy  |
------------------------------ 
|toy_id | name | description  |
------------------------------


--------------------
|table owned_toy  |
----------------------------
| owner  | toy_id          |
----------------------------


--------------------
|table toy_expansions |
-------------------------------
| expansion | toy_id          |
-------------------------------

I created a query to identify toys with no owner assigned

SELECT DISTINCT * from toy WHERE NOT EXISTS (SELECT * FROM ownedtoy WHERE owned_toy.toy_id = toy.id);

That worked and I was able to identify things that had no owner.

Now to make things more interesting I am trying to find out a way to discover how many expansions exist for each of the toys that I have identified in the query above.

I can count the total number of expansions to the toys using:

Select COUNT(expansion) from toy_expansions;

However what I need is to see the total number of expansions for each DISTINCT toy that does not yet have an owner, and it needs to be sorted so that I see the results from the first query combined with a column saying “number of Expansions” that lists the number of expansions for each toy identified to have no owner

I would like to be able to adding the results by combining the original query with a statement like this:

Select COUNT(expansion) as "Number of expansions" from toy_expansions

Also just to make it a little more difficult I would like to be able to execute it in one single query without creating extra tables etc. i.e. without making any changes to the db itself.

Any ideas ?

  • 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-24T00:19:41+00:00Added an answer on May 24, 2026 at 12:19 am
    SELECT t.name, COUNT(te.expansion) AS NumberOfExpansions
        FROM toy t
            LEFT JOIN toy_expansions te
                ON t.id = te.toy_id
            LEFT JOIN owned_toy ot
                ON t.id = ot.toy_id
        WHERE ot.toy_id IS NULL
        GROUP BY t.name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my issue: I need to close a process, already running, from a C#
I need some mind reading here, since I am trying to do what I
Here at work, we often need to find a string from the list of
Here's the situation: we have an Oracle database we need to connect to to
Here's another C#/.NET question based merely on curiousity more than an immediate need ...
I need to accept form data to a WCF-based service. Here's the interface: [OperationContract]
Having looked at some of the other mysql availability query questions on here has
I need to render some JSON based on my model, and I need to
We've had an ongoing need here that I can't figure out how to address
Here is a snippet of CSS that I need explained: #section { width: 860px;

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.