Psql replace blanks with character

Print Friendly

By wxornot

Well as the title describes, its a pretty straight forward problem. I have a series of psql tables where there are lots of blanks. However there is at least one column, called name, that will never be blank. I want to write a select statement to get all of the contents of the table and then turn blanks into a string like NULL. Here is my select statement idea, but I just don’t have a strong enough grasp on how the statement should look:



SELECT name,date,value
FROM table
WHERE value=’ ‘ print as “NULL“;

I don’t want to update the actual table, just print it without blanks. Obviously the above code doesn’t work, but hopefully you get the idea. I appreciate the help.

Dave

Source: FULL ARTICLE at The UNIX and Linux Forums

FavoriteLoadingAdd to favorites

Leave a Reply

Your email address will not be published. Required fields are marked *