且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如果值不为空,则用于更新数据库的 Sql 查询?

更新时间:2023-02-08 18:14:52

在不了解您的数据库的情况下,很难具体说明.在 SQL Server 中,语法类似于 ...

Without knowing your database it's tough to be specific. In SQL Server the syntax would be something like ...

UPDATE MyTable 
SET 
        Field1 = IsNull(@Field1, Field1),
        Field2 = IsNull(@Field2, Field2),
        Field3 = IsNull(@Field3, Field3)
WHERE 
     <your criteria here>

编辑

由于您指定了 SQLLite ...将我的 IsNull 函数替换为 COALESCE() 或查看 IfNull 函数.

Since you specified SQLLite ...replace my IsNull function with COALESCE() or alternately look at the IfNull function.