I have 5 Tables like this:
- TABLE 1: PRIMARY_KEY,NAME,FK_TABLE2
- TABLE 2: PRIMARY_KEY,FK_TABLE3
- TABLE 3: PRIMARY_KEY,FK_TABLE4
- TABLE 4: PRIMARY_KEY,FK_TABLE5
- TABLE 5: PRIMARY_KEY,DIAGRAM_NAME
And what I want is when I search for a name in a search bar, it returns Name from Table1, and also DIAGRAM_NAME from table 5.
The first part is easy:
SELECT `TABLE1`.name
from Table 1
Where `TABLE1`.name LIKE '%$search%'
But for the second part I need your help…
Thank you!
You need to look into using
JOIN:If you want to return the names that don’t have matching diagram names, use
LEFT JOINinstead.Good luck.