Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 尝试使用update语句和where子句更新数据库中的零件表_Sql_Ms Access - Fatal编程技术网

Sql 尝试使用update语句和where子句更新数据库中的零件表

Sql 尝试使用update语句和where子句更新数据库中的零件表,sql,ms-access,Sql,Ms Access,我正在尝试更新我的零件表,其中item\u class=HW,但我无法正确获取它。谁能看出我的语法有什么问题吗 update part set unit_price = unit_price + 1.05 where item_class = ' HW ' ; 它不提供错误,但不更新正确的行。它说它将要更新0行,而实际上需要更新4行。您是否有错误的空间尝试使用 update part set unit_price = unit_price + 1.05 where item_class lik

我正在尝试更新我的零件表,其中
item\u class=HW
,但我无法正确获取它。谁能看出我的语法有什么问题吗

update part
set unit_price = unit_price + 1.05
where item_class = ' HW ' ;

它不提供错误,但不更新正确的行。它说它将要更新0行,而实际上需要更新4行。

您是否有错误的空间尝试使用

update part
set unit_price = unit_price + 1.05
where item_class like  '*HW*' ;


如果不知道您的数据,很难说,但我看到了几个可能的问题。一个是“HW”周围的空格。根据该字段中的内容,很难确定正确的where子句是什么。如果HW是较长字符组的一部分(人们有时会错误地将逗号分隔的列表存储在访问字段中),则可能需要改用类函数。或者,删除不必要的空间可以解决问题。因此,从select语句开始:

Select * from part where item_class = ' HW ' ;
Select * from part where item_class = 'HW' ;
Select * from part where item_class like '*HW' ;
Select * from part where item_class like 'HW*' ;
Select * from part where item_class like '*HW*' ;
找到返回所需记录的文件后,请在update语句中使用该文件

我认为可能导致问题的其他方面是:

set unit_price = unit_price + 1.05
如果单价可以为空,则需要将其转换为0值,以使总和起作用。否则NULL加上任何金额=NULL。以下方法可能有效

set (IIf([unit_price] Is Null, 0, [unit_price]))+1.05

您在YOUR HW周围有两个空间。。这是对的吗?不,这是不对的,非常感谢。请把你的问题标题放在一些有意义的东西上。您重复了这些标记,这是完全无用的,删除它们会留下(update语句),这是无用的。你的标题应该以一种对在搜索结果中看到它的未来用户有意义的方式来解释你所问的问题或你所遇到的问题。好的,先生,我为给你带来的不便表示歉意。是的,我删除了空格,效果很好。非常感谢你,我觉得很傻,因为我把那些空间放进去了,却从来没有意识到。我用了最后一个。Access使用*而不是%作为通配符。请看,是的,第二个有效。这是那些意想不到的空间。非常感谢。
set unit_price = unit_price + 1.05
set (IIf([unit_price] Is Null, 0, [unit_price]))+1.05