Query SELECT DISTINCT sp.id sid, sp.title, sp.edition, sp.description, sp.source_url, sp.admin_notes, sp.created, CONCAT(u1.last_name, ', ', u1.first_name) created_by, sp.updated, CONCAT(u2.last_name, ', ', u2.first_name) updated_by, sf.filename, sf.size, stf.spec_file_link, e.id entity_id, e.name entity_name, st.abbr entity_state FROM specs sp INNER JOIN specs_to_files stf INNER JOIN specs_to_types stt LEFT JOIN users u1 ON sp.created_by = u1.id LEFT JOIN users u2 ON sp.updated_by = u2.id LEFT JOIN specs_to_entities ste ON ste.spec_id = sp.id LEFT JOIN entities e ON ste.entity_id = e.id LEFT JOIN entities_to_contacts ec ON ec.entity_id = e.id LEFT JOIN contacts c ON ec.contact_id = c.id LEFT JOIN states st ON c.state_id = st.id LEFT JOIN spec_files sf ON stf.spec_file_id = sf.id WHERE stf.spec_id = sp.id AND stt.spec_id = sp.id AND sp.id = city-sacramento-california-standard-specifications.pdf GROUP BY sp.id ORDER BY sp.created DESC failed with error Unknown column 'sacramento' in 'where clause'