Solved

Help, need phpmyadmin sql query for search & edit/delete

Posted on 2014-04-02
2
502 Views
Last Modified: 2014-04-03
I need an sql query to search "wp_postmeta" table for rows with meta_key "price" and meta_value more than 1 thousand (eg 1.084.51) and delete the first dot of the meta_value.
before: 1.084.51 -> after: 1084.51
I dont know if it is possible to do this with an sql query, anyway I hope it is possible.

Here is a picture:
price

Thanks in advance, Nicolas...
0
Comment
Question by:Nicolas Lagios
2 Comments
 
LVL 16

Accepted Solution

by:
Walter Ritzel earned 500 total points
ID: 39973923
the code is this:
update wp-postmeta
set meta_value = SUBSTR(CONVERT(CONVERT(REPLACE(META_VALUE,'.',''),DECIMAL(16))/100.00,CHAR),1,LENGTH(CONVERT(CONVERT(REPLACE(META_VALUE,'.',''),DECIMAL(16))/100.00,CHAR))-2)
where meta_key = 'price';

Open in new window


It could be improved a lot with regular expressions, but this way uses most basic mysql functions.
0
 

Author Comment

by:Nicolas Lagios
ID: 39975256
Actually accidentally in the first line between wp & postmeta you have add a dash instead of put an underscore.

The code is working 100%, thank you very much Walter Ritzel, appreciate for your time.

This is the code:

update wp_postmeta
set meta_value = SUBSTR(CONVERT(CONVERT(REPLACE(META_VALUE,'.',''),DECIMAL(16))/100.00,CHAR),1,LENGTH(CONVERT(CONVERT(REPLACE(META_VALUE,'.',''),DECIMAL(16))/100.00,CHAR))-2)
where meta_key = 'price';

Open in new window

0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now