duanhuangyun3887 2018-04-18 07:14
浏览 74
已采纳

查询错误,但我不知道它在哪里

I am already look closely and see I miss something or not. But idk, still error, I'm already make insert sort of from, depending relationship. but still wrong, here, my code

$whls = querywheels("SELECT 
        c.pn_car, pc.pn_partcar, pc.name_partcar, p.name_proses,
        p.name_proses, p.name_proses, tc.cost_total, sp.total_price,
        r.rate_year, sp.total_all FROM secondproses AS sp 

          JOIN proses    AS p  ON sp.proses_1     = p.id_proses
          JOIN proses    AS p  ON sp.proses_2     = p.id_proses
          JOIN proses    AS p  ON sp.proses_3     = p.id_proses
          JOIN toolscost AS tc ON sp.cost_idfk    = tc.cost_id
          JOIN partcar   AS pc ON tc.partcar_idfk = pc.id_partcar
          JOIN car       AS c  ON pc.id_carfk     = c.id_car
          JOIN year_rate AS r  ON tc.rate_idfk    = r.rate_id
        ");

and this is my tables enter image description here

this is my error

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result,
boolean given in C:\xampp\htdocs\hwbase\PHP\connect.php on line 17

this is my function

function querywheels($sql)
    {
        global $con;
        //query ambil data

    $result = mysqli_query($con,$sql);
    /*$whls = mysqli_fetch_assoc($result);*/
    $rows = [];
        while ($whs = mysqli_fetch_assoc($result)) //this is line 17 
       {
            $rows []= $whs;
            # code...
        }
        return $rows;
    }

EDIT : the error is I'm using 3 alias in different join. Even if in same table (thanks to Benjamin Caure, tell me where is my fault)

  • 写回答

1条回答 默认 最新

  • dongyashun2559 2018-04-18 07:19
    关注

    At least I can see this error: you cannot use same alias "p" on different joins, even if it's the same table

        JOIN proses AS p1 ON sp.proses_1 = p1.id_proses
        JOIN proses AS p2 ON sp.proses_2 = p2.id_proses
        JOIN proses AS p3 ON sp.proses_3 = p3.id_proses
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度