I've been able to make this code work using CodeIgniter's db->query
as follows:
$sql =
'SELECT mapping_code,zone_name,installation_name
FROM installations,appearances,zones
WHERE
installations.installation_id = zones.installation_fk_id
AND appearances.installation_fk_id = installations.installation_id
AND appearances.zone_fk_id = zones.zone_id
AND
appearances.barcode = ?
';
return $this->db->query($sql,array($barcode));
The 'appearances' table throws a 'not unique table' error if I try this using the Active Record class.
I need to join appearances on both the zone and installations tables.
How can I do this?