Laravel中的MySQL查询错误

Mujahidur Ra​​hman Mithun IUB

我正在使用laravel 5.4。尝试跑步时

select * from `users` inner join `addprojects` on `users`.`emp_id` = `addprojects`.`emp_id` where `emp_id` = $emp_id)"

它产生:

“SQLSTATE [23000]:完整性约束违规:1052列在where子句是不明确的'EMP_ID'(SQL:从选择*users内部联接addprojectsusersemp_id= addprojectsemp_id其中emp_id= $ EMP_ID)”

$emp_id= Auth::user()->emp_id;
$projects_for_emp = DB::table('users')->join('addprojects', 'users.emp_id', '=', 'addprojects.emp_id')->where('emp_id', '$emp_id')->get();
马蒂尔·拉赫曼·莫祖玛

emp_id在两个表中,因此可以使用users.emp_idaddprojects.emp_id

->where('users.emp_id', '=', $emp_id)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章