ホーム>source
<前>ウィズウィズ

私は public function flag_history() { $res=$this->db->query("SELECT pm1ticket.rep_id AS execut, pm1ticket.status_id, pm1contact_rep.f_name AS fname, pm1contact_rep.l_name AS lname, pm1ticket.due_date, pm1flag_history.id, flagid, from_id, to_id, MAX.time, ticketID, pm1flag_history.rep_id, pm1contact_rep.user_name, pm1contact_rep.f_name, pm1contact_rep.l_name, pm1ticket.subject FROM pm1flag_history JOIN pm1contact_rep ON pm1contact_rep.id = pm1flag_history.to_id JOIN pm1contact ON pm1contact.id = pm1ticket.customer_id JOIN pm1ticket ON pm1ticket.id = pm1flag_history.ticketID INNER JOIN( SELECT MAX(TIME) AS TIME, ticketID AS tkt FROM pm1flag_history WHERE from_id = " .$this->SESSION->userdata('TechUser_Id')." GROUP BY tkt ) MAX ON MAX.tkt = pm1flag_history.ticketID WHERE from_id = ".$this->SESSION->userdata('TechUser_Id')." AND flagid = 'rep' GROUP BY ticketID ORDER BY TIME DESC" ); //echo $this->db->last_query();die; $result=$res->result_array(); return $result; } を使用したというSQLクエリを持っています 。しかし、on句に不明な列 'pm1ticket.customer_id'が表示されています。

このエラーを解決する方法。誰か助けてください。

pm1ticket.customer_id
あなたの答え
  • 解決した方法 # 1

    以下のコードで試してください

    JOIN pm1ticket ON pm1ticket.id = pm1flag_history.ticketID
    JOIN pm1contact ON pm1contact.id = pm1ticket.customer_id

    これらの2行の順序は間違っていました。

    <前>ウィズウィズ

    この回答が役に立った場合は、これを受け入れて他の人を助ける

    public function flag_history() { $res=$this->db->query("SELECT pm1ticket.rep_id AS execut, pm1ticket.status_id, pm1contact_rep.f_name AS fname, pm1contact_rep.l_name AS lname, pm1ticket.due_date, pm1flag_history.id, flagid, from_id, to_id, MAX.time, ticketID, pm1flag_history.rep_id, pm1contact_rep.user_name, pm1contact_rep.f_name, pm1contact_rep.l_name, pm1ticket.subject FROM pm1flag_history JOIN pm1contact_rep ON pm1contact_rep.id = pm1flag_history.to_id JOIN pm1ticket ON pm1ticket.id = pm1flag_history.ticketID JOIN pm1contact ON pm1contact.id = pm1ticket.customer_id INNER JOIN( SELECT MAX(TIME) AS TIME, ticketID AS tkt FROM pm1flag_history WHERE from_id = " .$this->SESSION->userdata('TechUser_Id')." GROUP BY tkt ) MAX ON MAX.tkt = pm1flag_history.ticketID WHERE from_id = ".$this->SESSION->userdata('TechUser_Id')." AND flagid = 'rep' GROUP BY ticketID ORDER BY TIME DESC" ); //echo $this->db->last_query();die; $result=$res->result_array(); return $result; }

  • 前へ java - JPAクエリ:サブクエリをグループ化条件に結合する
  • 次へ pandas - PythonでNaNを最長の列の値で埋めます