【问题标题】:Filter dynamic e-commerce in PHP在 PHP 中过滤动态电子商务
【发布时间】:2020-02-12 04:11:58
【问题描述】:

post表是产品列表,post_feature是产品的特征,

posts 表的图片: enter image description here

帖子的图片特点: enter image description here

问题:如果我选择 id 1 和 3 功能,它应该只列出产品 id 5。但底部的 SQL 命令列出产品 id 8。

SELECT * FROM post_feature INNER JOIN posts ON 
post_feature.pfeature_postid=posts.post_id WHERE
post_feature.pfeature_featureid IN (implode(",",$ozellikler))

【问题讨论】:

    标签: php sql filtering e-commerce


    【解决方案1】:

    你可以用这个

    $sql = 'SELECT * FROM post_feature INNER JOIN posts ON post_feature.pfeature_postid=posts.post_id WHERE find_in_set(post_feature.pfeature_featureid, ' . $implode(",", $ozellikler) . ')';

    【讨论】:

    • 你能解释一下你的查询吗,它在做什么。
    • $post=DB::Connect()->query('SELECT * FROM post_feature INNER JOIN post ON post_feature.pfeature_postid=posts.post_id WHERE FIND_IN_SET(post_feature.pfeature_featureid, ' . implode(", ", $FilterValue) . ')')->fetchAll();错误:SQLSTATE [42000]:语法错误或访问冲突:1582 调用本机函数'FIND_IN_SET'中的参数计数不正确
    • 嗨 Ahmet,您可以阅读有关 find_in_set w3resource.com/mysql/string-functions/… 的信息
    猜你喜欢
    • 2021-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-23
    • 2015-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多