开发者

Select works, but can't update rows with a string of all spaces -- why?

开发者 https://www.devze.com 2023-04-02 08:21 出处:网络
This query SELECT count(data_id) FROM cdiac_data_AL WHERE (data_id >= 1 and data_id <= 30437) AND (TMIN_flags = \'\')

This query

SELECT count(data_id)
FROM cdiac_data_AL
WHERE (data_id >= 1 and data_id <= 30437) 
AND (TMIN_flags = '')

returns 844 records, but update query affects 0 records:

UPDATE cdiac_data_AL set TMIN_flags='   ' 
WHERE (data_id >= 1 and data_id <= 30437)  
AND ( TMIN_flags = '' )

What am I missing?

TMIN_flags is:

char(3) ascii_g开发者_开发知识库eneral_ci, allow null, default NULL  


It's because the CHAR data type does not save trailing spaces. You should change TMIN_flags data type to binary

0

精彩评论

暂无评论...
验证码 换一张
取 消