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

  • Home
  • SEARCH
  • 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 8604931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:41:55+00:00 2026-06-12T02:41:55+00:00

I have first database (dbA) with table like this, named Username : +——————+————–+ |

  • 0

I have first database (dbA) with table like this, named Username :

+------------------+--------------+
| Username         | PhoneNumber  |
+------------------+--------------+
| jamesbond007     | 555-0074     |
| batmanbegins     | 555-0392     |
+------------------+--------------+

then, on the other side, I have dbB with table like this, named PrivateMessage :

+------------------+---------------------------------+
| Username         | Message                         |
+------------------+---------------------------------+
| jamesbond007     | I need new bond-girl            |
| batmanbegins     | thanks for the paycheck, Nolan  |
+------------------+---------------------------------+

now, how to combine this two tables from 2 different databases so the output will look like this :

+------------------+--------------+---------------------------------+
| Username         | PhoneNumber  | Message                         |
+------------------+--------------+---------------------------------+
| jamesbond007     | 555-0074     | I need new bond-girl            |
| batmanbegins     | 555-0392     | thanks for the paycheck, Nolan  |
+------------------+--------------+---------------------------------+
  • 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-12T02:41:57+00:00Added an answer on June 12, 2026 at 2:41 am

    You can simply join the table of different database. You need to specify the database name in your FROM clause. To make it shorter, add an ALIAS on it,

    SELECT  a.*,          -- this will display all columns of dba.`UserName`
          b.`Message`
    FROM  dba.`UserName` a  -- or LEFT JOIN to show all rows whether it exists or not
          INNER JOIN dbB.`PrivateMessage` b    
             ON a.`username` = b.`username`
    

    but some how, there are possiblities where-in a username won’t have messages. In this case use LEFT JOIN if you want still to show all the records of dba.Username.

    Reading from your comments, the tables have different collation. The work around on this is to specify COLLATE on your joined statements,

    SELECT  a.*,          -- this will display all columns of dba.`UserName`
          b.`Message`
    FROM  dba.`UserName` COLLATE latin1_swedish_ci a  
          LEFT JOIN dbB.`PrivateMessage` COLLATE latin1_swedish_ci b    
             ON a.`username` = b.`username`
    

    you can change latin1_swedish_ci to whatever you want.

    For more info on COLLATION, see this full list of

    Character Sets and Collations in MySQL


    If you have enough privilege to ALTER the tables, simply use this syntax to manually convert and match their collations,

    ALTER TABLE tbl_name CONVERT TO CHARACTER SET latin2 COLLATE 'latin2_general_ci';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have like 400 records on my database, suppose this is the first version
i have 3 Tables is my SQL Database: First Table: Room: ID <pk>, Roomname
I have a database that is currently sharded. This is the first time that
I have a database framework where I have two tables. The first table has
I currently have this code which reads the first field in a database record
So I have a database with a few tables. The first table contains the
So this is my first app and first database. I think I have finally
I have database first application in mvc3. There is Rating table, it has ID
Hi i have a database first EF5 model defined. My user table has a
If I have use database first to build a context, and instantiate this context

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.