Hello everyone.
I have sort of an issue that I have stumbled on and don't know how to resolve it. Maybe someone can point me in the right direction here.
I have 3 tables like so:
Code:
dspatch
dispatch_Id
narrative
narrative_id
dispatch_id
narrative_Photo
photo_id
narrative_id
path
size
Here is some sample data from the narrative_Photo tale I am having a problem with:
Code:
photo_id narrative_id path size
1 1 /docs/1.jpg 1kb
Here is the sql I am using so far:
Code:
SELECT
`narrative_Photo`.`narrative_Photo_Id`,
`narrative_Photo`.`path`
FROM
`narrative_Photo`
Inner Join `narrative` ON `narrative`.`narrative_Id` = `narrative_Photo`.`narrative_Id`
Inner Join `dispatch` ON `dispatch`.`dispatch_Id` = `narrative`.`dispatch_Id`
WHERE
`dispatch`.`incident_Number_Id` = '1'
I need a second condition for the "dispatch_Id". My php code needs to first match the row where the dispatch_Id = something then insert the rest of the data.
I could get around this whole issue if I just put the PK from the incident table as the FK in the narrative_Photo table, effectively bypassing the incident table but that is not correct. I hope I am making myself clear.
Can someone please give me a hand?
Thanks