I’m having a problem with selecting data from my database. It show me following error
A Database Error Occurred
Error Number: 1054
Unknown column 'BA' in 'where clause'
SELECT * FROM crime_details INNER JOIN crime_slink ON crime_slink.report_ID =crime_details.report_ID INNER JOIN crime_suspect ON crime_suspect.id=crime_slink.suspect_id INNER JOIN crime_vlink ON crime_vlink.report_ID=crime_details.report_ID INNER JOIN crime_victim ON crime_victim.id=crime_vlink.victim_id WHERE crime_details.report_ID =BA-12-00002
Filename: C:\xampp\htdocs\CNPPO\system\database\DB_driver.php
Line Number: 330
It seems like the problem is in this part WHERE crime_details.report_ID =BA-12-00002
I think the problem was caused by the dashes or hyphens in my query.
Im using $this->db-query() function of codeigniter for my queries.
crime_details.report_IDholds aVARCHAR, so your where condition should bei.e., you need to wrap the value in quotes.
Also, instead of using
$this->db->query()to run your hand-written MySQL query, you should use ActiveRecord’s query builder which would have taken care of this for you. For example, you could have done: