SELECT * FROM表WHERE列LIKE%?%

Based on information here MySQL query String contains trying to create pdo query with ?

Experimented with following

SELECT * FROM Table WHERE Column LIKE %?%

SELECT * FROM Table WHERE Column LIKE ?%

SELECT * FROM Table WHERE Column LIKE %?

Nothing works. Get error

Syntax error or access violation: 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 '%...

Tried with SELECT * FROM Table WHERE Column LIKE ? but this is not for contains

Aim is to get query SELECT * FROM Table WHERE Column contains ?

What is is correct pdo contains statement for positional placeholders (?)?

try this by concatenating the value in the string via PHP,

$value = "valueHere";
$passThis = "%" . $value . "%";
// other pdo codes...
$stmt = $dbh->prepare("SELECT * FROM Table WHERE Column LIKE ?");
$stmt->bindParam(1, $passThis);
// other pdo codes...

after like add quotes. eg:- like '%?%'

i.e:

SELECT * FROM table_name WHERE column_name like '%field_name%';

If you would like to use prepared statements then take a look at http://php.net/manual/de/pdo.prepared-statements.php.

SELECT * FROM REGISTRY where name LIKE '%?%'

I think wildcard stament should be within single quotes, like;

SELECT * FROM Table WHERE Column LIKE '%?%';

This returns any record which contains the string given anywhere within the particular column field

Column data which starts with 'ber', example

SELECT * FROM Table WHERE Column LIKE 'ber%';

Hope this helps

Either put the % characters before and after your parameter before you pass it into the query or

SELECT * FROM Table WHERE Column LIKE '%' + ? + '%'

SELECT * FROM Table WHERE Column LIKE ? + '%'

SELECT * FROM Table WHERE Column LIKE '%' + ?

Although this will fail if ? is null because the concatenate will yield null. you could use coalesce

SELECT * FROM Table WHERE Column LIKE '%' + Coalesce(?,'') + '%'

SELECT * FROM Table WHERE Column LIKE Coalesce(?,'') + '%'

SELECT * FROM Table WHERE Column LIKE '%' + Coalesce(?,'')