Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Two operations - One column

Status
Not open for further replies.

DKailen

Technical User
Mar 6, 2010
13
US
I have a table that is all good except for one of the columns. In this column (~5500 entries) I have filenames basically such as graphic.jpg. I need to add "pics/" to the beginning of the column.

The other thing that I need is to place something like "No pic on file" where there are empty cells.

Is there an easy way to accomplish these things?

Thanks!
Jim


 
Sure, Use a couple of Update statements:

Code:
UPDATE mytable SET fieldname=concat("pics/",fieldname) WHERE fieldname !="" AND fieldname IS NOT NULL; 

and

UPDATE mytable SET fieldname="No pic on file" WHERE fieldname IS NULL OR filedname = "";


I suggest you run them on sample data just to make sure everything works as expected before running it on the actual table.

Also I added the check for null in case some of your fields are actually null instead of just being empty.


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Outstanding! I have been trying to get it to work since yesterday afternoon using the docs.....

Thanks much
Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top