提问人:nothes 提问时间:6/17/2023 最后编辑:ADysonnothes 更新时间:6/17/2023 访问量:27
从表中选择,其中某个或一个单词与给定字符串 [duplicate] 匹配
Select from a table where some or one of the word is matches from a given string [duplicate]
问:
我正在尝试使用 SELECT IN 语句使用分解和内爆的产品名称从我的一个表中获取结果。
$prd_exp = explode(" ", $product_bname);
$prd_in = implode(",", $prd_exp);
$getRecipies = $conn->prepare("SELECT * FROM recipes WHERE r_ind IN (?)");
$getRecipies->bind_param("s", $prd_in);
$getRecipies->execute();
$recipies__res = $getRecipies->get_result();
while($row = $recipies__res->fetch_assoc()) {
echo "> ".$row["r_name"]; // recipe name
}
r_ind包含这样的数据:糖、盐、面粉、鸡蛋
(单词,以逗号分隔)
用空格分解并用逗号内爆 $prd_in 如下所示:新鲜、鸡蛋、大小、L
因此,我想显示食谱,其中r_ind列包含单词 egg 或 $prd_in 字符串给出的任何其他单词。
在没有得到任何结果后,我确定我的sql逻辑是错误的。我进行了大量的搜索,但没有找到解决方案。
答: 暂无答案
评论
$prd_in