Basic wordpress based sql query help needed

I'm not big on SQL queries so could use a hand here..

In the wp_postmeta table I want to update all of the meta_value fields where the meta_key field is equal to either file_1, file_2 or file_3. I want to prepend the current content of meta_value with a string of text (string is currently image-1.jpg or similar).

I'm comfortable running a query through phpmyadmin. Any help greatly appreciated!

Solutions

You could try with:

UPDATE wp_postmeta
SET meta_value=CONCAT("image-1.png", meta_value)
WHERE meta_key="file_1" OR meta_key="file_2" OR meta_key="file_3";

Try it before. I didn't test it.

Something like this should work. See Update Syntax.

UPDATE wp_postmeta
SET meta_value =  CONCAT("image-1.jpg", meta_value)
WHERE meta_key IN(file_1, file_2, file_3);
Tags: Mysql / Wordpress

Similar questions

Wordpress user dashboard custom left menu example code help needed
I need help to show the left menu item on other role users dashboard. I am using the code at plugin to add the custom admin menu items . The menu is being displayed and working at admin dashboard. But not being displayed at other users dashboard. I am being logged in through Wordpress basic users login section. I have added the line below, Subscrib...
3 column WordPress layout help needed
I'm busy trying to put together a 3x3 magazine-style layout for the home page of my blog. I want the divs containing each post to flow vertically so there aren't big white spaces beneath each row of 3. It seems like the easiest way to do this would be to have three columns and fill each of these (which will stop there from being a big space beneath...
WordPress 3.6.1 + Turbolink + Pace.js help needed
I've tried to install Pace.js script on my own blog — http://www.thewired.ru and I have some feeling that I've failed a bit. Can someone of you please tell me what's going wrong with it? Problem is that sometimes it does not work and sometimes it works not smoothly. What's wrong? Thanx in advance.
Modifying wordpress default search to custom search, code help needed
I am working on WordPress, I am modiyfing the form to my new form, it has 3 fields as below I don't know how do I do this, I tried below code snippet but didn't work for me. \ Search Results - My page id="post-"> Posted on: by No results found
Wordpress multiple featured image hover help needed (php/jquery) - think I'm 80% there
I wanted to have the featured header images in my blog posts change to alternative images on hover - all of my header images are black and white so the idea is to have them change to high contrast monotone versions when hovering... I followed the guidance of this tutorial, and after a few bumps in the road I'm now at the final hurdle where I add so...
wordpress url rewrite help needed
I have a wordpress site and has template page. I am passing class ID as cid parameter. http://www.example.com/class-details/?cid=51 I want it to have like http://www.example.com/class-details/ I wrote rule below in .htaccess RewriteRule ^class-details/?([^/]*)$ example.com/class-details/$1 [NC,R,L] It leads to recursive redirection. I tried checkin...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.