gpt4 book ai didi

php - 如果列不为 NULL,如何更新表中的列?

转载 作者:行者123 更新时间:2023-11-29 02:44:23 24 4
gpt4 key购买 nike

我有一个将数据提交到表格的表单。除了 received_dategid 之外,其他用户可以编辑表格列。如何在 PHP 更新脚本期间跳过该列?

这是 default_table(简化):

gid     received_date     detail     max_number   status
1 NULL NULL NULL 1

第一次输入后:

gid     received_date         detail     max_number   status
1 2017-07-17 Swimsuit 100 1

经过秒等输入:

gid     received_date          detail     max_number   status
1 2017-07-17 Swimsuit XL 250 1

可能是这样的:

UPDATE t_goods 
IF(t_goods.received_date = NULL){
SET received_dates = received_date(today_date), detail = detail, max_number = add_stock WHERE gid = gid
}
ELSE{
SET detail = detail, max_number = add_stock WHERE gid = gid
}

注意:查询只是一个伪代码。

最佳答案

像那样尝试。

UPDATE t_goods 
SET
detail = detail,
max_number = add_stock,
received_date = IF(received_date IS NULL, received_dates,received_date)
WHERE gid = gid;

IF(received_date IS NULL, received_dates,received_date) 如果 received_date 为 null,此等式更新新的 received_dates 值,否则它将 received_date 保持为旧值。

关于php - 如果列不为 NULL,如何更新表中的列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45140548/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com