I'm trying to work out: If I have three joined tables, i.e tableA<-->tableB<-->tableC
How to always have tableA's records and NULL values in B&C if they don't exist? See http://www.sqlfiddle.com/#!9/65dd5/6
The second example will naturally return nothing, and there's no matching IDs in either the second or third tables, but I still need to return the contents of TableA
==== EDIT =====
I don't think I've been very helpful in providing info. My bad!.
Here's the actual query:
SELECT
cf_definitions.id,
cf_definitions.`name`,
cf_definitions.parentmodel,
cf_definitions.type,
cf_definitions.`options`,
cf_definitions.class,
cf_definitions.description,
cf_joins.cf_definitionid,
cf_joins.cf_childid,
cf_joins.cf_valueid,
cf_values.id,
cf_values.`value`
FROM
cf_definitions
LEFT JOIN cf_joins ON cf_joins.cf_definitionid = cf_definitions.id
LEFT JOIN cf_values ON cf_joins.cf_valueid = cf_values.id
WHERE
cf_definitions.parentmodel = 'location' AND cf_joins.cf_childid = 1
So if I've got records with a join entry, then it's fine.
However, what I really need is (in pseudo code) IF cf_joins.cf_childid doesn't exist, still return the records from cf_definitions.
(to put this in context, this is for custom form fields, where I'm essentially definining the form schema in definitions, then 'if' the page has values (which is the childid), then return the rows complete with values, otherwise return null values).
I appreciate I might be going against what a JOIN is actually meant to do?