當會話StaffID匹配reports
表中的StaffID時,我試圖從report
檢索所有報告。會話ID匹配表時獲取數據
Report_Name, ReportDate and ReportID are part of the report table
這是我覺得應該去
從report
其中ReportID
獲取ReportID
,Report_Name
和ReportDate
從Read_Report
比賽ReportID
從report
當會話StaffID
= StaffID
在Read_Report
和th是我的查詢
function get_read_report()
{
$this->db->select('report.Report_Name, report.ReportDate, report.ReportID')
->from('Read_Report')
->join('Read_Report', 'report.ReportID = Read_Report.ReportID')
->where('StaffID', $this->session->userdata("StaffID"));
return $result = $this->db->get();
}
我得到這個錯誤
錯誤編號:1066
Not unique table/alias: 'Read_Report' SELECT `report`.`Report_Name`, `report`.`ReportDate`, `report`.`ReportID` FROM `Read_Report` JOIN `Read_Report` ON
report
。ReportID
=Read_Report
。ReportID
WHEREStaffID
= '3'Filename: models/report/Report_model.php Line Number: 91
控制器代碼
function my_read_reports()
{
$data = array();
if ($query = $this->report_model->get_read_report()) {
$data['reports'] = $query;
}
$this->template['middle'] = $this->load->view($this->middle = 'pages/read_reports_view', $data, true);
$this->layout();
}
你只是錯過了正確的表在加盟的時候。 –