如何使用mysql检查带有where子句的Apostrophe

How is an apostrophe (') used with the WHERE clause in MySQL?

I have used mysql_real_escape_string to sanitise input already.

Here is a screenshot of my mySQL query and database

SELECT * FROM players WHERE `name` = 'Amar'e Stoudemire'

enter image description here

Executing this query generates the following error:

enter image description here

Any idea why?

SELECT * FROM players WHERE `name` = 'Amar\\''e Stoudemire'

If your cell content is \' then you have to escape both characters:

\ --> \\
' --> ''

Single quotes can be escaped with themselves in MySQL - like so:

SELECT * FROM players WHERE `name` = 'Amar\''e Stoudemire'

I Found my answer thanx for juergen d who help me out to solve this query

<?php 
$name = "Amar'e Stoudemire";
?>

This is the string with Apostrophe and if you want to check this string in mysql Query with where clause so here is the solution

<?php 
$name = addslashes(addslashes($name));
/*Amar\\\'e Stoudemire*/
?> 

SELECT * FROM players WHERE `name` = "'.$name.'"