Link to home
Start Free TrialLog in
Avatar of oldmillsaddlery
oldmillsaddleryFlag for United Kingdom of Great Britain and Northern Ireland

asked on

I need letters added to contents of a field in a database if other letters are present.

My table name is "webstockforuploadrob" and the field name is "thumb nail image name". An example of one of the field contents is XX152TH.jpg. I need a query that adds P1 before the TH.jpg if TH.jpg is present. The result should read XX152P1TH.jpg Hope someone can help
ASKER CERTIFIED SOLUTION
Avatar of Dimitris
Dimitris
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry the where is like thsi
WHERE RIGHT(image_name,5)='TH.jpg' :)
Avatar of oldmillsaddlery

ASKER

thanks for this but I am not getting it totally correct. I have a table called newwebstock and one of the fields is called Thumbnail Image name

 UPDATE NEWWEBSTOCK SET Thumbnail_Image_name = REPLACE(Thumbnail_Image_name,'TH.jpg','P1TH.jpg')
WHERE RIGHT(Thumbnail_Image_name,5)='TH.jpg';


when I run the query it asks me to enter parameter value for  Thumbnail_Image_name

Sorry it is something stupid I am doing I guess
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
in the original question, you state
the field name is "thumb nail image name".  
in the query you posted, you have the name as  
 Thumbnail_Image_name
which is it, as it cannot be both.  The fact that you are getting a prompt for that 'parameter' name (Thumbnail_Image_name) suggests that the field is actually named  
thumb nail image name
Avatar of awking00
Can you post a describe for newwebstock so we can see actual field name? Also, you can eliminate additional executions by adding -
and RIGHT(Thumbnail_Image_name,7) <>'P1TH.jpg';
Thanks all I seem to have got things sorted with the file name
Glad to be of assistance.  Just need to be sure that once this query has been executed, that it is not executed again, as I noted, above.
 
AW
By the way, it should be
where right(<fieldname>,6) = 'TH.jpg'
and right(<fieldname>,8) <> 'P1TH.jpg'