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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:35:49+00:00 2026-06-02T07:35:49+00:00

I have this structure in my MySQL database: +————–+ +————–+ | table_1 | |

  • 0

I have this structure in my MySQL database:

   +--------------+    +--------------+
   |    table_1   |    |    table_2   | 
   +----+---------+    +----+---------+  
   | id |   name  |    | id | surname |  
   +----+---------+    +----+---------+  
   | 1  | tbl1_1  |    | 1  | tbl2_1  |  
   | 2  | tbl1_2  |    | 2  | tbl2_2  |   
   | 3  | tbl1_3  |    | 3  | tbl2_3  |  
   +----+---------+    +----+---------+   

I need a query that returns this:

   +----+---------+---------+
   | id |   name  | surname |
   +----+---------+---------+
   | 2  | tbl1_2  | tbl2_2  |
   +----+---------+---------+

I searched in google, what I found is UNION which does this:

   +----+---------+
   | id |  name   |
   +----+---------+
   | 2  | tbl1_2  | 
   | 2  | tbl2_3  |
   +----+---------+  

which is not what I look for. I need they are combined next to each other, not on top of each other.

  • 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-02T07:35:52+00:00Added an answer on June 2, 2026 at 7:35 am

    you need to use an JOIN, the type of join based on your requirement.

    SELECT id,name,surname FROM table_1 INNER JOIN table_2 on table_2.id=table_1.id WHERE table_1.id = 2
    

    The INNER JOIN will select all rows from both tables as long as there is a match between the id columns we are matching on i.e the ids exist in both the tables

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mySQL table called clients with this structure: Name | Phone |
I have a table in a MySQL Database which has this structure: CREATE TABLE
I have a MySQL database with a structure like this... Site has many Sensors
I have a MySQL database table with this structure: table id INT NOT NULL
Ok so i have a database table called requests with this structure mysql> desc
I have a MySQL table structured somewhat like this: type name value ===================== 1
I have a MySQL database with the following table structure: TransactionType : Transaction_Amount, Transaction_ID,
I have a table setup in my database with this structure: I have running
I'm new to mysql. Right now, I have this kind of structure in mysql
In my MySQL database, I have this Time data type as one of my

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.