Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为什么我的查询不按子字符串匹配?_Php_Mysql - Fatal编程技术网

Php 为什么我的查询不按子字符串匹配?

Php 为什么我的查询不按子字符串匹配?,php,mysql,Php,Mysql,我想在我的网站上使用我自己的脚本,目前我有: SELECT recipes.name, recipes.details, recipes.img_URL, ingredients.recipe_ID, products.name, count(*), recipes.added_by, recipes.id FROM recipes Inner Join ingredients ON recipes.ID = ingredients.recipe_ID Inner Join products O

我想在我的网站上使用我自己的脚本,目前我有:

SELECT
recipes.name,
recipes.details,
recipes.img_URL,
ingredients.recipe_ID,
products.name,
count(*),
recipes.added_by,
recipes.id
FROM
recipes
Inner Join ingredients ON recipes.ID = ingredients.recipe_ID
Inner Join products ON ingredients.product_ID = products.ID
WHERE
products.name = $value
GROUP BY
recipes.ID ORDER BY
count(*) DESC
但是它的问题是,如果我搜索像egg这样的词,它将不会找到eggs,我已经尝试了like命令,但它不起作用


有什么想法吗?

mysql搜索的通配符是%

更改搜索,使SQL查询不是=$value,而是$value%-
例如,egg%

mysql搜索的通配符是%

更改搜索,使SQL查询不是=$value,而是$value%-
例如,egg%

你只是在寻找一种找到复数的方法吗?我当然希望你用$value=mysql\u real\u escape\u string$value来逃逸$value;或者你将遭受SQL注入是的,我所有的值都被转义了,Lol,你只是在寻找一种找到复数的方法吗?我当然希望你用$value=mysql\u real\u escape\u string$value来转义$value;否则您将遭受SQL注入是的,所有我的值都将转义为select recipes.name、recipes.details、recipes.img\u URL、components.recipe\u ID、products.name、count、recipes.added\u by、,recipes.id FROM recipes Inner Join Components ON recipes.id=配料。recipes\u id Inner Join products ON Components.product\u id=products.id其中products.name='%egg%'或products.name='%ham%'按配方分组。id按计数排序说明不起作用,也不起作用。。选择recipes.name、recipes.details、recipes.img_URL、配料.recipe_ID、products.name、count、recipes.added_by、,recipes.id FROM recipes Internal Join Components ON recipes.id=Components.recipes\u id Inner Join products ON Components.product\u id=products.id其中products.name='egg%'或products.name='ham%'按配方分组。id按计数排序DESCah我修复了它,需要将=更改为类似的select recipes.name,recipes.details,recipes.details,recipes.img\u URL,配料.recipe\u ID,products.name,count,recipes.added\u by,recipes.ID FROM recipes in Join components ON recipes.ID=配料.recipe\u ID in Join products ON components.product\u ID=products.ID其中products.name='%egg%'或products.name='%ham%'按配方分组.ID按计数排序说明不起作用,也不起作用。。选择recipes.name、recipes.details、recipes.img_URL、配料.recipe_ID、products.name、count、recipes.added_by、,recipes.id FROM recipes Internal Join Components ON recipes.id=Components.recipes\u id Inner Join products ON Components.product\u id=products.id其中products.name='egg%'或products.name='ham%'按配方分组。id按计数排序DESCah我修复了它,需要将=更改为类似值