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

时间:2011-04-21 09:03:22

标签: 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 ON ingredients.product_ID = products.ID
WHERE
products.name = $value
GROUP BY
recipes.ID ORDER BY
count(*) DESC

但问题是,如果我搜索像“egg”这样的单词,它将找不到“egg”,我尝试了LIKE命令,但dosnt可以正常工作。

有什么想法吗?

1 个答案:

答案 0 :(得分:3)

mysql搜索的通配符是%。

更改您的搜索,以便= $value代替SQL查询,而不是LIKE $value% - 即,鸡蛋%

相关问题