Here is the query that almost works:
$query = '';
$query .= ' SELECT highway_code.charge_id,
highway_code.act_abbr,
highway_code.short_form_wording,
highway_code.section,
highway_code.set_fine,
highway_code_arrest_jail_tow.demerits
';
$query .= ' FROM highway_code, highway_code_arrest_jail_tow ';
$query .= ' WHERE highway_code.charge_id = ? ';
$query .= ' AND highway_code.section = highway_code_arrest_jail_tow.section ';
$query .= ' AND highway_code.act_abbr = highway_code_arrest_jail_tow.act_abbr ';
The problem is that not all highway code charges have demerits, thus any charges without demerits are not returned, even though all the other fields apply. I would like to have all charges returned regardless if there is a value in highway_code_arrest_jail_tow.
LEFT JOINinstead of the implicitINNER JOINyou have here (via comma-separated table names) Review codinghorror.com/blog/2007/10/…