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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:28:36+00:00 2026-05-25T01:28:36+00:00

I am new to MySql/PHP. Each row from Database1.table1 has to be read and

  • 0

I am new to MySql/PHP.

Each row from Database1.table1 has to be read and display. It contains a column which has search term that I need to pass on to Database2.table2 and process the returns per each row read. Currently I am making new connection to Database2.table2 for each row in db1.table1 which is really slow and inefficient. I can not change the table structures.

Thanks!

tables

db1 table1:

id_row    type        model        har               status    id         date         
1         ATX         Hybrion      88-85-5d-id-ss    y         aaa12345   2011/08/12
2         BTX         Savin        none              n         aaa12345   2010/04/05
3         Full        Hp           44-55-sd-qw-54    y         ashley a   2011/07/25
4         ATX         Delin        none              _         smith bon  2011/04/05

db2 table2:

id_row    id          first_name   last_name    dept    telephone
1         aaa12345    joe          smith        ANS     800 555 5555
2         bbb67890    sarah        brown        ITL     800 848 8848

So the database 1 table 1 is the one that gets read and displayed, db2 table2 is read and info displayed if ID is positive match. ID is only unique in the db2 table2, db1 table1 one has multi format column so it could or could not be an ID as well as those rows could have duplicate ID. Hope this gives better understanding of what i need. Thanks again!

Someone suggested to use EXISTS but I don’t know how, given the situation.

  • 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-05-25T01:28:37+00:00Added an answer on May 25, 2026 at 1:28 am

    Assuming the user you’re running as has the correct rights to see both databases, then you should be able to do this by joining the tables using the ‘dbname.tablename’ syntax like this:

    select t1.*, t2.*
    from database1.table1 t1
    LEFT OUTER JOIN database2.table2 t2 ON t1.id = t2.id
    

    this will give you all rows from table A, and where there is a matching row in table b, the matching rows from there as well (or nulls if there is no matching row)..

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

Sidebar

Related Questions

I am having trouble showing a row from a database which has a list
I am new to MySQL and PHP(as you can probably tell) and I was
I've done a fair bit of mysql php programming but am pretty new to
I started doing a new project in PHP / MySql . The Aim of
MySQL connection in PHP can be established in two ways: $mysql = new mysqli('localhost',
I am fairly new to MySQL and have a project in which I need
New to mysql and php, so forgive any obvious stupidity, please! One of mysql
I am pretty new to both php and mysql. I have a txt file
I am trying to display images vertically 5 per row using php and I
My MySQL table contains 2 fields and I want to create a new parameter

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.