我想在查询中将名字和姓氏作为全名连接起来。$query = $this->db->select('CONCAT(w.firstName," ",w.lastName) as fullName,w.ID,w.firstName,w.lastName, w.firstname_ar, w.lastname_ar, w.cin , w.tel, w.tel2, w.poste_id, w.gender, w.date_birth, w.address, w.address_ar, w.familySituation, w.socialSecurity, w.typeContract, w.period,w.email,w.status,r.name,w.conge as cng,w.startDateContract, w.pictureProfile, w.endDateContract, w.dateTitulation, w.rib, w.languages, w.passport, w.passport_end_date, w.urgent_phone, w.urgent_phone_name,w.pointage_id as idpointeur, w.shift_start as heure_arr, w.shift_end as heure_dep, w.worker_role as workerRole, r.color as roleColor, r.name as departement, conge_annee, c.name as companyName, c.logo as logoCompany, p.title as poste',FALSE)->from('Workeforce w')->join('Role r', 'r.ID = w.RoleID')->join('Company c', 'c.ID = w.CompanyID')->join('poste p', 'p.id = w.poste_id', 'left')->where('w.worker_role <', 100);它给了我这个错误。致命错误: 未捕获异常: SQLSTATE[42S22]: 列未找到: 1054 未知列 “CONCAT(w.firstName” 在 /Users/mac/www/application/core/models/workeforce_model.php:100 堆栈跟踪: #0
1 回答

蝴蝶不菲
TA贡献1810条经验 获得超4个赞
尝试转义 CONCAT 中的引号。
您的错误显示“'CONCAT(w.firstName'”不是有效的列,这一事实向我表明您的数据库认为SELECT在那里结束。
CONCAT(w.firstName,\" \",w.lastName) as fullName, ....
在引号前面添加 \ 将对其进行转义。
您可以在此处阅读有关转义特殊字符的更多信息:https://dev.mysql.com/doc/refman/8.0/en/string-literals.html
- 1 回答
- 0 关注
- 110 浏览
添加回答
举报
0/150
提交
取消