You have an error in your SQL syntax near 'AND '/batavia-ny-timewarner.html' LIKE CONCAT(dynamic_pages.beginurl,'%') AND '/' at line 1