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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:35:54+00:00 2026-06-06T22:35:54+00:00

I have 5 tables in my Mysql database with t1 with field name like

  • 0

I have 5 tables in my Mysql database with t1 with field name like data,id,cool and 4 other tables with id and data say t2,t3,t4,t5.

I have used join and sub queries but result i am getting is empty set its not mandatory that all the fields in the t2,t3,t4,t5 tables are populated .t4,t5,t3,t2 can be empty i am using where clause on data if data column of t1 = t2 = t3 = t4 = t5 if it finds any matching data in any of the table it prints the cool from t1 and id and data from found table if any and if founds the data match in all the table it prints all the table stats like

cool data.t1 id.t1
cool data.t2 id.t2 
and so on



table t1

cool data id
0    xyz   1

table t2

data id
xyz   5

table t3

data id
xyz   4

table t4

data id
xyz   3

table t5

data id
xyz   2

desired output

cool data id
  0   xyz  1
  0   xyz  4
  0   xyz  3
  0   xyz  5
  0   xyz  2

if any of the table is empty say t5 and t4 than output should be

 cool data id
  0   xyz  1
  0   xyz  4
  0   xyz  3
  • 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-06T22:35:56+00:00Added an answer on June 6, 2026 at 10:35 pm

    What i understand from the question is you need to get data from table t1 for all other tables for all matching data and id column in respective table.

    A simple way to achieve is to join each table with t1 seperately and then use union all to combine all results.

    SELECT t1.cool, t2.data, t2.id
    FROM t1 INNER JOIN t2 ON (t1.id=t2.id) AND (t1.data=t2.data)
    UNION ALL
    SELECT t1.cool, t3.data, t3.id
    FROM t1 INNER JOIN t3 ON (t1.id=t3.id) AND (t1.data=t3.data)
    UNION ALL
    SELECT t1.cool, t4.data, t4.id
    FROM t1 INNER JOIN t4 ON (t1.id=t4.id) AND (t1.data=t4.data)
    UNION ALL
    SELECT t1.cool, t5.data, t5.id
    FROM t1 INNER JOIN t5 ON (t1.id=t5.id) AND (t1.data=t5.data)
    

    as from your example, it is quite possible that there can be duplicate records To filter them out use distinct like this –

    SELECT DISTINCT cool, data, id
    FROM
    (
    -- above query here
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple tables in a MySQL database. Lets say they look like this:
I have been using FSharpDAL to read data tables in Mysql database. It works
I have a MySQL Database. In it's table is a field called 'itm_name' I'm
I have a calendar table in my MYSQL database with one field named datefield
I have a table with a field of type date within a MySQL database.
I have an customer invoice table in my MySQL database with a DECIMAL(10,2) field
I have two tables in my MySQL database, one is a library of all
I have three tables in a Mysql database - countries, cities and hotels. Their
I have two tables in a MySql database: COUNTRY --------------- id, country_name and CITY
I have multiple tables in a mysql database and I am trying to put

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.