我需要获取UserID_Staff
与会话StaffID
匹配的数据
我的查询
$this->db->select('Report_Comments.Comments, Report_Comments.Comment_Date staff.Staff_Username')
->from('Report_Comments')
->join('staff', 'Report_Comments.UserID_Staff = staff.StaffID')
->where('UserID_Staff', $this->session->userdata("StaffID"));
return $result = $this->db->get();
任何想法为什么我会收到此错误,以及如何更改我的查询?
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.`Staff_Username` FROM `Report_Comments` JOIN `staff` ON `Report_Comments`.`User' at line 1
SELECT `Report_Comments`.`Comments`, `Report_Comments`.`Comment_Date` `staff`.`Staff_Username` FROM `Report_Comments` JOIN `staff` ON `Report_Comments`.`UserID_Staff` = `staff`.`StaffID` WHERE `UserID_Staff` = '3'
Filename: models/report/Report_model.php
Line Number: 115
答案 0 :(得分:0)
$this->db->select('Report_Comments.Comments, Report_Comments.Comment_Date ,staff.Staff_Username')
->from('Report_Comments')
->join('staff', 'Report_Comments.UserID_Staff = staff.StaffID')
->where('UserID_Staff', $this->session->userdata("StaffID"));
return $result = $this->db->get();
你想念','靠近Report_Comments.Comment_Date , staff.Staff_Username