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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:13:55+00:00 2026-06-10T00:13:55+00:00

I have $mySQL = $db -> prepare(SELECT table1.users,table1.name,table2.img,table2.name,table2.users FROM table1,table2 WHERE table1.users = table2.users);

  • 0

I have

$mySQL = $db -> prepare("SELECT table1.users,table1.name,table2.img,table2.name,table2.users FROM table1,table2 WHERE table1.users = table2.users");

$row = $mySQL->fetch(PDO::FETCH_ASSOC);

I can echo out :

echo $row['name'];

But how does it know to get name from table1 or table2? Can I do something like

echo $row['table1.name'];

Thanks

Also, is this the best way to get data from multiple tables? Thanks

  • 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-10T00:13:57+00:00Added an answer on June 10, 2026 at 12:13 am

    Add alias to identify your table.

    SELECT table1.users as tab1user,table1.name,table2.img,table2.name,table2.users as tab2user
     FROM table1 JOIN table2 in table1.users = table2.users
    

    Best way to JOIN tables. it’ll improve performances.
    You have to select suitable join method according to your requirement. follow this link for JOIN

    http://www.w3schools.com/sql/sql_join.asp

    Edit :
    *JOIN 3 Tables*

     select ......
     FROM table1 JOIN table2 in table1.users = table2.users
     JOIN Table3 in table2.id=table3.id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have this function that takes all the users from an MySql table
I have the following PHP function which will list the users from a MySql
I have MySQL InnoDB table utf-8 encoded. This table has only id and name
I have mysql database and I want a software which can draw the database
I have MySQL running such that I can open a client command line and
I'm trying to get a mysql PDO statement to select all of the failed
So I'm trying to select the username from the users table BASED ON if
I have a mysql table, I want to check if a row exists where
As you can see I'm trying to fetch rows from table while using prepared
I have a table in a mysql-database with the fields name, title, cd_id, tracks

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.