Results 1 to 6 of 6
i have a table with a column in it there are like 2000 entries down this column... the table name is "products" and the column is "products_image" example: 1234.jpg 321.jpg ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 08-09-2006 #1
"find and replace" in SQL??
the table name is "products" and the column is "products_image"
what SQL query should i use to replace *.jpg with *.gif down the entire column??
i dont know squat about SQL...
- 08-09-2006 #2
Globbing is not a good idea in SQL, as changes remain permanent. You will find there aren't many ways to do it either. There are no for loops in sequel. I would suggest using a select query to take all the details:
use your_database_name select products_image from picture
update products set products_image = '1234.gif' where products_image = '1234.jpg' update products set products_image = '321.gif' where products_image = '321.jpg'
It's not how any coder likes to do things, but with SQL I never take chances.
PS Don't forget to backup before any bulk inserts!
- 08-09-2006 #3Originally Posted by bigtomrodney
can i do *.jpg and *.gif????
- 08-09-2006 #4
Well the wildcard in SQL is % rather than * when you are working with strings. * means all. I'm not sure if it would work to do a %.jpg/%.gif. I know you can embed mysql statements into bash, maybe someone here can jump in and take over. Unfortunately my SQL experience is mainly from MSSQL Server, and I haven't done much with MySQL on and Unix systems.
- 08-10-2006 #5Originally Posted by bigtomrodney
- 08-28-2006 #6
- Join Date
- Aug 2006
I was looking for the same thing kinda...
Here is what I got:
SET products_image = stuff(products_image,len(products_image)-3,3,'gif')
where (products_image like '%.jpg')
Please note - I used this on SQL server
You may have to fudge around with the numbers to lop-off the jpg and insert the gif.
Hope this helps