one-to-many with many only having the foreign key
one-to-many with many only having the foreign key
so, based on this: https://editor.datatables.net/manual/php/array-joins
I can't find a way say to have a one-to-many (without a link table) where the "one" part doesn't have the foreign key, whereas the "many" part has the foreign key. It seems that both need to have a foreign key.
Is there a way for me to query this with the "one" part not having the foreign key?
table:
One Job, many Evidence:
---------------------
JobID, JobName
--------------------
---------------------
EvidenceID, EvidenceName, JobID (foreign key)
-------------------
or would I need to use where for this?
This discussion has been closed.
Answers
note:
I tried doing this via join:
at first, i did ->join(....->join('JobID','EvidenceID'))....then I realized that JobID was being treated as the foreign key in Jobs, and EvidenceID as the foreign key for Evidence table (or so from what I'm understanding)
EDIT: I might have figured out what's wrong with my code LOL