skip to Main Content

In phpmyAdmin I would like to DELETE the content of meta_value fields in wp_postmeta table, if the content has a certain string.

When I’m using SELECT to show the rows first, my code is working and all rows with the founded string are shown correct. But if I use DELETE instead of SELECT, I’m getting the following error:
Unknown table ‘meta_value’ in ‘MULTI DELETE’

This is my code:

DELETE pm.meta_value FROM wp_postmeta pm 
LEFT JOIN wp_posts wp ON wp.ID = pm.post_id 
WHERE wp.post_type = 'person' 
AND pm.meta_key = 'gallery' 
AND pm.meta_value LIKE '%mystring%';

What did I do wrong? Thanks in advance!

2

Answers


  1. Chosen as BEST ANSWER

    As @Akina said, the problem was, that I used DELETE instead UPDATE, to modify or delete a single field.


  2. Could you please try to check with the given slightly modified query. In this we have meta_value with pm.meta_value.

    DELETE pm.meta_value FROM wp_postmeta pm 
    LEFT JOIN wp_posts wp ON wp.ID = pm.post_id 
    WHERE wp.post_type = 'person' 
    AND pm.meta_key = 'gallery' 
    AND pm.meta_value LIKE '%mystring%';
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search