I need to make a MySQL query to show data from 3 diferents tables.
This is the table 1:
TABLE1
-
id
-
reference
-
name
-
email
This is the table 2:
TABLE2:
-
id
-
phone
This is the table 3:
TABLE3:
-
id
-
phone
I need to show all data from table1, and also the phone from table2 or table3, only if the id in table2 or table3 is the same number that is in the reference field in table1.
Any advice? Thank you!
You can try something like
Have a look at COALESCE(value,…) and maybe SQL SERVER – Introduction to JOINs – Basic of JOINs