2024-04-20 13:43:39 发布
网友
该函数处理sql请求。它接收参数,其中一个参数可以是“null”或值(uuid), 我需要将此值添加到where。 但是有一个问题,因为使用null 其中param为空,但值为“where param=value”
范例
sql = '''select name from table where param = %s ''' def run_sql(param=None): a = db_api(sql, param)
select name from table where param is not distinct from %s
在sql中,null = null和null <> null总是计算为false,因为空值被视为未知值,不能被视为彼此相等或不相等
null = null
null <> null
false
但是两个null值彼此不不同,因此null is not distinct from null的计算结果为true
null
null is not distinct from null
true
在sql中,
null = null
和null <> null
总是计算为false
,因为空值被视为未知值,不能被视为彼此相等或不相等但是两个
null
值彼此不不同,因此null is not distinct from null
的计算结果为true
相关问题 更多 >
编程相关推荐