Welcome Guest, Not a member yet? Register   Sign In
Whats wrong with this query?
#1

[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_ %'




Theme © iAndrew 2016 - Forum software by © MyBB