Reputation: 183
In my DB column I have this:
2017/05/imagename.png
and I need just:
imagename.png
I was trying something like this:
UPDATE wp_postmeta
SET `meta_value` = replace(meta_value, left(meta_value, INSTR(meta_value, '/')-1),'')
WHERE `meta_key` LIKE '_wp_attached_file'
But after using this query, I get this result:
05/imagename.png
Any idea how could I fix my query?
Upvotes: 1
Views: 57
Reputation: 1269703
Your code looks like mysql. If so, you can use substring_index()
:
update wp_postmeta
set meta_value = substring_index(meta_value, '/', -1)
where meta_key LIKE '_wp_attached_file';
Upvotes: 2