reggie
reggie

Reputation: 3674

Query results that have less than X characters in MySQL

Some submitters have submitted location strings that are too short. How can I query them to remove them in phpMyAdmin?

The query would look like this (ending is obviously pseudo code):

SELECT `post_id` FROM `wp_postmeta` 
WHERE `meta_key` = 'location' 
AND `meta_value` HAS LESS THAN 10 CHARACTERS

Upvotes: 2

Views: 1728

Answers (1)

BenOfTheNorth
BenOfTheNorth

Reputation: 2872

SELECT `post_id` FROM `wp_postmeta` WHERE `meta_key` = 'location' AND CHAR_LENGTH(meta_value) < 10

Upvotes: 4

Related Questions