0

I am try select from mysql database with this

select * from mytable where where name like '%job's you%');

It's give me error message. How to fix it? thank for you help!

  • 4
    Possible duplicate of [How to escape apostrophe (') in MySql?](http://stackoverflow.com/questions/9596652/how-to-escape-apostrophe-in-mysql) – Jonathon Reinhart Feb 27 '17 at 10:33
  • Possible duplicate of [How to escape single-quote (apostrophe) in string using php](http://stackoverflow.com/questions/39634968/how-to-escape-single-quote-apostrophe-in-string-using-php) – e4c5 Feb 27 '17 at 10:47

4 Answers4

0

The ' in job's is escaping your query and the ) shouldn't be there. Try:

select * from mytable where where name like '%job\'s you%';
HomerPlata
  • 1,687
  • 5
  • 22
  • 39
0

You have two time where , an improper ) and you have a single quote inside so you should wrap with double quotes

select * from mytable where name like "%job's you%";
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107
0

The ' in "job's" is escaping your query, you can try:

select * from mytable where where name like "%job's you%"

BGH
  • 56
  • 1
  • 6
0

Use real_escape_string.

$variable = $mysqli->real_escape_string("job's you");
$query = $mysqli->query("select * from mytable where where name like '%".$variable."%')");

Please follow the link for more details.

Manish
  • 3,443
  • 1
  • 21
  • 24