mysql中字段大小n a_MySQL:如果存儲過程中的選定字段具有NULL值,我想將N / A作為值返回...

I'm using phpmyadmin and I have the following stored procedure:

我正在使用phpmyadmin,我有以下存儲過程:

SELECT im.onset_date,

im.end_date,

im.coding_id,

im.patient_id,

im.resolution_circumstances,

FROM illness_mapping as im

WHERE im.patient_id = p_id and im.end_date <= CURDATE()

p_id value is insert by the user.

p_id值由用戶插入。

In some records im.resolution_circumstances is null. When I call the stored procedure I want to find if it's null and return the value N/A. I only want to return the value and not to store it to the specific field in the database.

在某些記錄中,im.resolution_circumstances為null。當我調用存儲過程時,我想查找它是否為null並返回值N / A.我只想返回值,而不是將其存儲到數據庫中的特定字段。

Do you have any idea?

你有什么主意嗎?

1 个解决方案

#1

1

You can use case to check whether your property is null or not

您可以使用大小寫來檢查您的屬性是否為null

SELECT im.onset_date,

im.end_date,

im.coding_id,

im.patient_id,

(case

when im.resolution_circumstances is null

then "N/A"

when im.resolution_circumstances is not null

then im.resolution_circumstances

end) as resolution_circumstances

FROM illness_mapping as im

WHERE im.patient_id = p_id and im.end_date <= CURDATE()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值