Solved

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

Posted on 2014-04-02
2
525 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

634 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