这是我在laravel刀片中的模型功能。在这里我有两个表"admins"
和"candidates"
使用连接查询我加入两个表。但是在运行我的代码时我可能会得到以下提到的内容
错误。
if ( Input::has('recordcreator') and $request->input('recordcreator') != NULL){
$querys->join('admins','admins.adminid','=','candidates.createdby');
$querys->where('admins.firstname', 'LIKE', '%'. $request->input('recordcreator') .'%')->orWhere('admins.lastname', 'LIKE', '%'. $request->input('recordcreator') .'%')->where('admins.status','1');
}
SQLSTATE [23000]:完整性约束违规:1052列 '姓名' in order子句不明确(SQL:select * from rsi_candidates rsi_admins.adminid =上的内连接rsi_admins rsi_candidates.createdby其中rsi_admins.lastname LIKE%ic% 和rsi_admins.status = 1或rsi_admins.firstname LIKE%ic% 按rsi_candidates.candidateid分组,按名字命名为asc limit 20偏移0)
答案 0 :(得分:1)
As i see your laravel error you may add the table name in front of your firstname column in orderby clause
或者你也可以试试这个解决方案
open your database.php file located in config directory
Config->database.php in your mysql database array add this.
'strict'=>假,