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

xxls0lw8  于 2021-06-25  发布在  Mysql
关注(0)|答案(1)|浏览(341)

我已经在仔细观察,看我是否错过了什么。但idk,还是错了,我已经犯了 insert 从某种程度上说,取决于关系。但还是错了,这里,我的密码

$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
        ");

这是我的table

这是我的错误

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

这是我的职责

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;
    }

编辑:错误是我在不同的连接中使用了3个别名。即使在同一张table上(感谢本杰明·考尔,告诉我哪里是我的错)

gk7wooem

gk7wooem1#

至少我可以看到这个错误:不能在不同的联接上使用相同的别名“p”,即使它是同一个表

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

相关问题