I have three tables such as "tbl_purchase", "tbl_user" & "tbl_contestant". I need all records from tbl_purchase with "name" that has in two tables "tbl_user" & "tbl_contestant".
My Query,
SELECT tp.*, tu.*
FROM tbl_purchase tp
INNER JOIN tbl_user tu
ON tu.user_id = tp.user_id
Table: tbl_purchase
+-------+-------------+------+
| p_id | user_id | Star |
+-------+-------------+------+
| 1 | 1 | 50 |
| 2 | 4 | 100 |
| 3 | 6 | 150 |
+-------+-------------+------+
Table: tbl_user
+-------+-------------+
| u_id | name |
+-------+-------------+
| 1 | Sachin |
| 4 | Akshay |
+-------+-------------+
Table: tbl_contestant
+-------+-------+-------------+
| c_id | u_id | Name |
+-------+-------+-------------+
| 1 | 6 | Mayank |
| 2 | 8 | Nikhil |
| 3 | 9 | Vipul |
+-------+-------+-------------+
I want below result,
+-------+-------+-------------+------+
| p_id | u_id | Name | Star |
+-------+-------+-------------+------+
| 1 | 1 | Sachin | 50 |
| 2 | 4 | Akshay | 100 |
| 3 | 6 | Mayank | 150 |
+-------+-------+-------------+------+