What would the SQL statement be to delete part of a string from an entry.
i want to change imi/picture.jpg to picture.jpg in over 250 entries.
I tried winging it with this:
DELETE 'imi/' IF EXISTS 'Pictures'
but obviously it is incorrect.
can anyone help?
Query Question.
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
DELETE is to delete a row. You need an UPDATE.
If it's always the same string you're removing then try:
EDIT | Make sure you have a backup first!
If it's always the same string you're removing then try:
Code: Select all
update tablename set fieldname = substr(fieldname,4) where substr(fieldname,1,4) = 'imi/';note: when i actually did this with this command, i still ended up with /img_photo.jpg, not img_photo.jpg
in fact, when i rewrote it as:
it still didn't remove the slash. does this command not remove slashes?
in fact, when i rewrote it as:
Code: Select all
update tablename set fieldname = substr(fieldname,1) where substr(fieldname,1,1) = '/';