【发布时间】:2020-05-25 15:21:16
【问题描述】:
我尝试检查关系表中的列是否为空,.但是使用我当前的代码,我得到一个错误。
第二个whereNotNull中的列是"best_match"。
SQLSTATE[42P01]:未定义表:7 错误:缺少 FROM 子句条目 对于表“问题”↵LINE 1:
$questions = Model::whereNotNull('question_id');
if($excepted_questions){
$questions->whereNotIn('id', $excepted_questions);
}
$questions->where('votes', '!=' , $confidence_specs->votes)
->orWhere('weight', '!=' , $confidence_specs->weight)
->with('questions')
->inRandomOrder();
//HERE I try to check if that column is null or not
if($confidence_specs->best_match){ // this can be true / false ,if is true I check if that column is null
$questions->whereNotNull('questions.best_match');
}
$questions->limit($nr_of_questions)
->get();
【问题讨论】:
-
使用 $questions = Question::whereNotNull('question_id');
-
请再次阅读说明。问题来自代码中的第二个 whereNotNull。
-
转储 $questions->toSql() 并查看查询内容。
-
给出 $questions->whereNotNull('best_match');并尝试
-
我更新了问题。看起来就是这样,但我不使用 whereNotNull 进行 best_match。