Solved

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

Posted on 2014-04-02
2
492 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 15

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Re-imbursement Claim System 3 25
uploading multiple image with php 14 20
Paging Using PHP 7 34
masking php string 4 11
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
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…

747 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

12 Experts available now in Live!

Get 1:1 Help Now