I have a table that has a string value of 'null' that I wish to replace with an actual NULL value.
However if I try to do the following in my select
Select Replace(Mark,'null',NULL) from tblname
It replaces all rows and not just the rows with the string. If I change it to
Select Replace(Mark,'null',0) from tblname
It does what I would expect and only change the ones with string 'null'
You can use NULLIF
:
SELECT NULLIF(Mark,'null')
FROM tblname;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.