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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:31:14+00:00 2026-06-07T18:31:14+00:00

I have a two tables TabA and TabB. TabA is in DB_A and TabB

  • 0

I have a two tables TabA and TabB. TabA is in DB_A and TabB in ‘DBX’_B.

Now I need to get the DBX_B name from a field from TabA of DBA and join them in a query to pull the data from both these tables.

 DBA.TabA:
 ID        DB_Name      UserName    Password
 -------------------------------------------
 101       DBX          xyz         abc


 DBX_B.TabB:

 ID        Type      FirstName      LastName
 -------------------------------------------
 101       Admin     xyz            abc

I need to pull ID, Username, Password from DBA.TabA and pull Type, Firstname, LastName from DBX_B.TabB. But the 2nd database name to use can be identified from DB_NAME and concat it with string like _B'. So the 2nd database to pull from isDBA.TabA.DB_Name’ + _B.
Join these two tables on ID from both.

The query can look something like:

  SELECT DBA.TabA.ID, DBA.TabA.Username, DBA.TabA.Password, 
         DB2.TabB.Type, DB2.TabB.FirstName, DB2.TabB.Lastname 
    FROM DBA, CONCAT(DBA.TabA.DB_Name, '_B') as DB2
   WHERE DBA.TabA.ID = DB2.TabB.ID

Of course, we can use Join too instead of where.

Is something like this possible? 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-06-07T18:31:15+00:00Added an answer on June 7, 2026 at 6:31 pm

    You could possibly do this with some subSelects, but performance will take a huge hit, to the point that it just won’t be worth it. You might be better off pulling your tables into whatever your middle tier is (php?) and joining the data together in there. How you do that will depend on what your middle tier is.

    There is something flawed in your database design, if you are still in the design phase, STOP, and redesign, hire someone if you have to, getting your Data model designed correctly now will save you so much future pain. If you are maintaining something and stuck with what you have, using the middle tier will be your best bet.

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

Sidebar

Related Questions

I have two tables users and work_orders. Now I need to get work_orders results
I have two tables: A, B. I need to select all data from B.
I have two tables :- tbl_ticket_categories(id,category_name,site_referer) tbl_tickets(id,title,category_name,site_referer) I have to get all title from
I have two tables one with ID and NAME table 1 ID | NAME
I have two tables user table user_id | name | 1 | peter |
I have two tables. Table Emp id name 1 Ajay 2 Amol 3 Sanjay
I have two tables, Users and TempUsers and I need to do operations on
I have two tables Master Detail In the Master & Detail table I get
I have two tables: Events (ID, Name, Time, Recorder) Video (ID, StartTime, EndTime, Recorder,
I have two tables as students and certificates, I need to delete the certificates

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.