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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:09:31+00:00 2026-06-18T05:09:31+00:00

I have 3 mysql tables show below. in this case, tbl_a is join table

  • 0

I have 3 mysql tables show below. in this case, tbl_a is join table relating tbl_b and tbl_c. I would like to denormalize tbl_a

tbl_a schema

b_id, c_id, id, x,y,z

tbl_b schema

id, a, b, c

tbl_c schema

id, d, e, f

The idea is that for each id in tbl_a, I want to replace b_id and c_id with the full entries from their respective tables.

I have the query

select a,b,c,d,e,f,x,y,z from tbl_a
INNER JOIN tbl_b on tbl_a.b_id = tbl_b.id
INNER JOIN tbl_c on tbl_a.c_id = tbl_c.id;

But this results in 2 rows for each id in tbl_a.

Can someone explain why this doesn’t work?

  • 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-18T05:09:32+00:00Added an answer on June 18, 2026 at 5:09 am

    any chance to have duplicate id’s in tbl_a?

    the query is correct – check http://sqlfiddle.com/#!8/9c666/1

    CREATE TABLE `tbl_a` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `b_id` int(11) NOT NULL,
      `c_id` int(11) NOT NULL,
      `xyz` varchar(30) NOT NULL,
      PRIMARY KEY (`id`)
    ) ;
    
    CREATE TABLE `tbl_b` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `abc` varchar(30) NOT NULL,
      PRIMARY KEY (`id`)
    ) ;
    
    CREATE TABLE `tbl_c` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `def` varchar(30) NOT NULL,
      PRIMARY KEY (`id`)
    ) ;
    
    
    INSERT INTO `tbl_b` (`id`, `abc`) VALUES
    (1, 'b1'),
    (2, 'b2'),
    (3, 'b3'),
    (4, 'b4');
    
    
    INSERT INTO `tbl_c` (`id`, `def`) VALUES
    (1, 'c1'),
    (2, 'c2'),
    (3, 'c3');
    
    
    INSERT INTO `tbl_a` (`b_id`, `c_id`, `xyz`)
    SELECT (ABS(CRC32(UUID())) % 4) + 1, (ABS(CRC32(UUID())) % 3) + 1, SUBSTRING(UUID(), 3, 5);
    
    SELECT * FROM tbl_a;
    
    SELECT * FROM tbl_a
    INNER JOIN tbl_b on tbl_a.b_id = tbl_b.id
    INNER JOIN tbl_c on tbl_a.c_id = tbl_c.id;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table which looks like this: mysql> SHOW COLUMNS FROM Users; +------------+--------------+------+-----+---------+----------------+
I have two MySQL tables something like this: tool_owners: tool_owners_id | user_id | ...
I have a simple Message table, with 2 indexes: mysql> show keys from Message;
I have two MySQL tables, j and t, with a third normalising table, jt.
I have this mysql tables I want to display with jqgrid. The problem appears
I have like below: After I have changed show entries to 25 in datatable,
I have a MySQL query like this written in PHP: $merkki = $_GET[merkki]; //
Development language and DB: PHP/MySQL I have a table geo_places with something like 8
I'm using a MySQL database. I have two tables, Table 1 and Table 2.
I use PHP and MySQL and I have 2 tables: table score: have fields

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.