Search code examples
phpmysqlsqlrecordset

Concatenating the symbol in recordset of a PHP


In my record set I am taking countrycode using GET operator and sending it to the query as a parameter and I am using LIKE operator for this query like this.

$query_getzone = "SELECT distinct LocationId FROM all_dropdown WHERE LocationId LIKE '".$country.".'-%'";

I am getting an error '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 '-%'' at line 1'. Please help me with this.


Solution

  • try this,

    $query_getzone =  "SELECT distinct LocationId FROM all_dropdown WHERE LocationId LIKE '$country-%'";;