在 sql 查询中使用 Like 时不会返回任何结果


No results are returned when using Like in sql query

我在使用 PHP 的 MySQL 时遇到了语法问题。

我的代码:

$q['item_desc LIKE ''%?%''"'] = array($criteria);

但它被转换为SQL查询:

SELECT `Item`.`id`, `Item`.`item_desc`, `Item`.`row_num`, `Item`.`shelf_num`, `Item`.`shelf_loc`, `Item`.`datetime` FROM `inventory`.`items` AS `Item` WHERE `item_desc` LIKE '%'10'%'"

我相信我需要摆脱%内的单引号.我该怎么做?

那里有一个不需要的双引号。

尝试

$q['item_desc LIKE ''%?%''']

$q["item_desc LIKE '%?%'"]