DarkMoria
DarkMoria

Reputation: 90

How to select information from more then one table in MySQL Database using PHP and mySQli, has to be combined single query

I am confused on how to query multiple tables at once and how to combine them. What is the proper why to combine multiple SELECT queries in it's simplest form?

$id = 2;
$result = conn()->query("

     SELECT * FROM members WHERE id='$id'
     UNION
     SELECT * FROM users_meta WHERE id='$id'

");

Edit 3-5-2016

Speed tips for reading lots of data for MySqli.

Upvotes: 0

Views: 74

Answers (1)

Abhishek Sharma
Abhishek Sharma

Reputation: 6661

Try join

SELECT * FROM members m join users_meta u
     on m.id=u.id
     WHERE m.id='$id'

Upvotes: 1

Related Questions