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

The Archive Base Latest Questions

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

I am trying to join these two tables I created so that the resultset

  • 0

I am trying to join these two tables I created so that the resultset has 3 entries for each type.

Data table

mysql> SELECT * FROM data;
+--------------+-----------+
| Labels       | Data      |
+--------------+-----------+
| Component    | 1325.1988 |
| Component    |  554.1652 |
| Component    |  105.4002 |
| Development  |  203.4163 |
| Development  |   59.4500 |
| Development  |   20.4498 |
| Flash Assets |  285.5334 |
| Flash Assets |  302.1501 |
| Flash Assets |   61.1836 |
| Release      |    0.6000 |
| Release      |    2.3666 |
| Repackage    |  416.2169 |
| Repackage    | 5195.0839 |
| Repackage    |    4.5667 |
| Source Diff  |    1.9000 |
| Source Diff  |    0.4000 |
+--------------+-----------+

Types table

mysql> SELECT * FROM types ORDER BY Labels;
+------------------------+------+
| Labels                 | Data |
+------------------------+------+
| Component              |    0 |
| Component              |    0 |
| Component              |    0 |
| Development            |    0 |
| Development            |    0 |
| Development            |    0 |
| Flash Assets           |    0 |
| Flash Assets           |    0 |
| Flash Assets           |    0 |
| Release                |    0 |
| Release                |    0 |
| Release                |    0 |
| Repackage              |    0 |
| Repackage              |    0 |
| Repackage              |    0 |
| Source Diff            |    0 |
| Source Diff            |    0 |
| Source Diff            |    0 |
+------------------------+------+

Current Query:

mysql> SELECT * FROM data d LEFT JOIN types t on t.Labels = d.Labels;
+--------------+-----------+--------------+------+
| Labels       | Data      | Labels       | Data |
+--------------+-----------+--------------+------+
| Component    | 1325.1988 | Component    |    0 |
| Component    | 1325.1988 | Component    |    0 |
| Component    | 1325.1988 | Component    |    0 |
| Component    |  554.1652 | Component    |    0 |
| Component    |  554.1652 | Component    |    0 |
| Component    |  554.1652 | Component    |    0 |
| Component    |  105.4002 | Component    |    0 |
| Component    |  105.4002 | Component    |    0 |
| Component    |  105.4002 | Component    |    0 |
| Development  |  203.4163 | Development  |    0 |
| Development  |  203.4163 | Development  |    0 |
| Development  |  203.4163 | Development  |    0 |
| Development  |   59.4500 | Development  |    0 |
| Development  |   59.4500 | Development  |    0 |
| Development  |   59.4500 | Development  |    0 |
| Development  |   20.4498 | Development  |    0 |
| Development  |   20.4498 | Development  |    0 |
| Development  |   20.4498 | Development  |    0 |
| Flash Assets |  285.5334 | Flash Assets |    0 |
| Flash Assets |  285.5334 | Flash Assets |    0 |
| Flash Assets |  285.5334 | Flash Assets |    0 |
| Flash Assets |  302.1501 | Flash Assets |    0 |
| Flash Assets |  302.1501 | Flash Assets |    0 |
| Flash Assets |  302.1501 | Flash Assets |    0 |
| Flash Assets |   61.1836 | Flash Assets |    0 |
| Flash Assets |   61.1836 | Flash Assets |    0 |
| Flash Assets |   61.1836 | Flash Assets |    0 |
| Release      |    0.6000 | Release      |    0 |
| Release      |    0.6000 | Release      |    0 |
| Release      |    0.6000 | Release      |    0 |
| Release      |    2.3666 | Release      |    0 |
| Release      |    2.3666 | Release      |    0 |
| Release      |    2.3666 | Release      |    0 |
| Repackage    |  416.2169 | Repackage    |    0 |
| Repackage    |  416.2169 | Repackage    |    0 |
| Repackage    |  416.2169 | Repackage    |    0 |
| Repackage    | 5195.0839 | Repackage    |    0 |
| Repackage    | 5195.0839 | Repackage    |    0 |
| Repackage    | 5195.0839 | Repackage    |    0 |
| Repackage    |    4.5667 | Repackage    |    0 |
| Repackage    |    4.5667 | Repackage    |    0 |
| Repackage    |    4.5667 | Repackage    |    0 |
| Source Diff  |    1.9000 | Source Diff  |    0 |
| Source Diff  |    1.9000 | Source Diff  |    0 |
| Source Diff  |    1.9000 | Source Diff  |    0 |
| Source Diff  |    0.4000 | Source Diff  |    0 |
| Source Diff  |    0.4000 | Source Diff  |    0 |
| Source Diff  |    0.4000 | Source Diff  |    0 |
+--------------+-----------+--------------+------+

My goal with the left join was to get all of the labels from the Types table so that there would be Three entries for each label in the resultset. For some reason it comes out funky.

Desired Output:

+--------------+-----------+
| Labels       | Data      |
+--------------+-----------+
| Component    | 1325.1988 |
| Component    |  554.1652 |
| Component    |  105.4002 |
| Development  |  203.4163 |
| Development  |   59.4500 |
| Development  |   20.4498 |
| Flash Assets |  285.5334 |
| Flash Assets |  302.1501 |
| Flash Assets |   61.1836 |
| Release      |    0.6000 |
| Release      |    0      |
| Release      |    2.3666 |
| Repackage    |  416.2169 |
| Repackage    | 5195.0839 |
| Repackage    |    4.5667 |
| Source Diff  |    1.9000 |
| Source Diff  |    1.9000 |
| Source Diff  |    0      |
+--------------+-----------+

Here there are three entries for each label and the data is replaced with the zeros from the types table

Any help would be great.

  • 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-24T11:11:41+00:00Added an answer on May 24, 2026 at 11:11 am

    Have you tried following query:

    SELECT t.Labels, COALESCE(d.Data, 0) 
    FROM data d 
    LEFT JOIN types t on t.Labels = d.Labels;
    
    1. Why you need data column in Types table
    2. Consider ID column in Types table and TypeId in Data table
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to join two tables. One being the sys.databases table and the
I am trying to join two EJB's using EJBQL (with an underlying MySQL data
I have in my MySQL database these two tables: CREATE TABLE IF NOT EXISTS
I'm trying to join multiple tables, but one of the tables has multiple records
I am trying to join two tables; the purpose being able to search and
I have a 3 tables that I'm trying to join and get distinct results.
I'm trying to LEFT JOIN two tables, to get a list of all rows
I have two tables that I'm trying to create a relationship between so I
With of these two approaches would you prefer: trying to find the right data-types
I'm using two tables for my current project(it will grow certainly). First table has

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.