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
Add alias to identify your table.
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*