CodeIgniter Forums
Whats wrong with this query? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Whats wrong with this query? (/showthread.php?tid=48464)



Whats wrong with this query? - El Forum - 01-17-2012

[eluser]Andy78[/eluser]
Getting an sql error here not sure how to append the LIKE clause at the end. It works without the LIKE

Code:
//build the sql query
$this->CI->db->select("code, latitude, longitude");
$this->CI->db->where("latitude BETWEEN '$min_lat' AND '$max_lat'");
$this->CI->db->where("longitude BETWEEN '$min_lon' AND '$max_lon'");
$this->CI->db->where("WHERE code LIKE 'FK_ %'");
$result = $this->CI->db->get("postcodes");


Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'code LIKE 'FK_ %'' at line 5

SELECT `code`, `latitude`, `longitude` FROM (`postcodes`) WHERE `latitude` BETWEEN '55.8616' AND '56.1508' AND `longitude` BETWEEN '-3.9507' AND '-3.6131' AND `WHERE` code LIKE 'FK_ %'