我有以下查询
SELECT * FROM answers where (id_question in (select id from questions where id_quiz = 3))
我需要知道如何用laravel eloquent
来写它答案 0 :(得分:2)
Answer::whereIn('id_question', function($query) {
$query->table('questions')->where('id_quiz', 3)
})->get();
答案 1 :(得分:2)
table
方法不再有效,请改用from
方法
Answer::whereIn('id_question', function($query) {
$query->from('questions')->where('id_quiz', 3)
})->get();