php - MySQL filtering with several inner joins

Solution:
SELECT
Entities.*,
Locations.Loc_Name as Loc_Name
FROM
Entities
INNER JOIN Locations ON Entities.Obj_ID=Locations.Obj_ID
WHERE
Entities.Ent_Type='Locations'
AND Loc_Name LIKE ?
UNION
SELECT
LocEnt.*,
Locations.Loc_Name as Loc_Name
FROM
TimeSensatives
INNER JOIN Entities AS CharEnt ON TimeSensatives.Ent_ID=CharEnt.Ent_ID
INNER JOIN Characters ON Entities.Obj_ID=Characters.Obj_ID
INNER JOIN Entities AS LocEnt ON TS_Content.Ent_ID=LocEnt.Ent_ID
INNER JOIN Locations ON LocEnt.Obj_ID=Locations.Obj_ID
WHERE
TS_Type='Location'
AND TS_Start<=?
AND TS_End>=?
AND Char_Name LIKE ?
will give you all needed locations plus their names
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: using $this when not in object context laravel
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.