本文介绍了我在选择时从laravel的数据库中获得了空白值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到一个问题,我想从数据库中获取 start_date
,但是我只得到空值,它没有显示值。
I am facing a problem that I want to get start_date
from database, but I get only null values, it's not showing values.
请检查此图片以更好地理解:
Please check this image for better understanding: https://imgur.com/eCrGeTW
这是代码:
$data = \DB::table("subscriptions")
->select("subscriptions.*",
\DB::raw("(SELECT subscriptions.start_date FROM subscriptions
WHERE subscriptions.business_id = $business_id
) as date"))
->orderBy('subscriptions.start_date', 'desc')
->get();
dd($data);
推荐答案
我已经通过以下代码解决了我的问题:
I have solved my problem with the following code:
$datestart = \DB::table('subscriptions')->where('business_id', $business_id)->Orderby('id','desc')->value('start_date');
谢谢,伙计们
这篇关于我在选择时从laravel的数据库中获得了空白值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!