我正在执行此查询以从不同的表中获取详细信息。 如果用户存在于表上,则要打印行值,否则打印空格。但是没有正确输出。
$users = DB::table('user_form_submission')
->join('recommend_email_send_by_cron', 'recommend_email_send_by_cron.user_id','=','user_form_submission.id')
->select('recommend_email_send_by_cron.business_id as businessId',
'recommend_email_send_by_cron.email as email',
'user_form_submission.id as userId',
'recommend_email_send_by_cron.name as name',
'recommend_email_send_by_cron.status as status',
'recommend_email_send_by_cron.sign_in_data as sign_in_time',
'recommend_email_send_by_cron.sent_time as mail_sent_time',
'user_form_submission.created_at as created_at',
'user_form_submission.form_id as formId',
DB::raw("(CASE WHEN (select user_id from track_button_events where (recommend_email_send_by_cron.user_id = user_id) && (recommend_email_send_by_cron.business_id = business_id)) THEN 'Yes' ELSE '' END) as noButtonClicked"),
DB::raw("(CASE WHEN (select user_id from recommend_feedback_details where (recommend_email_send_by_cron.user_id = user_id) && (recommend_email_send_by_cron.business_id = business_id)) THEN recommend_feedback_details.feedback ELSE '' END) as message"),
DB::raw("(CASE WHEN (select user_id from recommend_yes_button_track where (recommend_email_send_by_cron.user_id = user_id) && (recommend_email_send_by_cron.business_id = business_id)) THEN 'Yes' ELSE '' END) as yesButtonClicked"),
DB::raw("(CASE WHEN (recommend_email_send_by_cron.status= 'sent') THEN 'Yes' ELSE '' END) as mail_sent"
)
->where('user_form_submission.business_id', '=', $businessId)
->get();
print_r($users)
错误:
'字段列表'中的未知列'recommended_feedback_details.feedback'