PDA

View Full Version : SQl Syntax Help


kronnos
03-17-2011, 12:46 AM
Hi,

I wanted to set a certain text for a user profile filed if it is currently blank.
So i want to try something like

UPDATE userfield SET field5 = REPLACE(field5,'IF THIS IS BLANK','REPLACE WITH NEW TEXT');

I dont know what to use in "IF THIS IS BLANK" because if I leave that spot blank, nothing happened. So should I use NULL in that place or completely rewrite the line so it says not replace but set?

thanks!

OcR Envy
03-24-2011, 04:10 PM
UPDATE userfield SET field5='Your Replacement Text' WHERE field5 = '';

kronnos
08-08-2012, 11:39 AM
Thanks! Its great!