if you want to keep the row with the lowest id value:
DELETE n1 FROM table n1, table n2 WHERE n1.id > n2.id AND n1.meta_key = n2.meta_key
OR if you want to keep the row with the highest id value:
DELETE n1 FROM table n1, table n2 WHERE n1.id < n2.id AND n1.meta_key= n2.meta_key
Related Posts:
- Query WordPress database by registered date and role
- SQL query to set posts in bulk based on the post content
- SQL Query to get post_id from wp_posts and and meta_key(s) from wp_postmeta
- Inserting Post Meta From SQL
- Change SQL get_results to search for posts with custom term in custom taxonomy
- Change all http to https in mysql databse?
- WooCommerce – Query for ordered products
- How to execute mulitple statement SQL queries using $wpdb->query?
- Size article thumbnails and retrieve them directly from database
- How to query the WordPress database to get posts of a certain custom post type, taxonomy and field?
- Select Multiple meta_value from WP DB; Single Query
- wpdb_prepare with multiple or condition
- SQL Error wp_commentmeta – incorrect table definition
- CRUD operations using WordPress database API
- WordPress and MySQL: how to transfer Meta_key and Meta_Value from one post_id to another
- How do I get the posts within a certain year/date(with sql query)?
- Advanced SELECT query with condtional statements
- Slow queries constantly getting stuck on WordPress database of ~100,000 posts
- Create table from array with prepare
- How to fix database error duplicate entry
- Query multiple tables at once?
- Custom WordPress Table wpdb
- Why this query is not showing any result on wordpresss home page?
- Best practice to limit results in get_row()?
- Why does changing Database Table Prefixes result in loss of content?
- Query Column of Specific ID from Database Table
- $wpdb->get_var – What value is returned when zero records are found?
- How to display data from db in select list [closed]
- DB prefix not updating
- I wanted to Know that how can I give ingore to 0000-00-00 in my config file
- Job and Employee Performance Tracking with Product Safety
- WordPress Database Query works in phpMyAdmin but not in the code
- How to create index (sql) to a meta_key?
- Delete all users meta that named: user_avatar
- The MySQL Connection could not be established., before it was joomla but i have change it into worpress
- Migrated to Namecheap, now Trouble with Database & wp-config [closed]
- export individual posts to text files or a single csv file
- SQL query : Select a thumbnail for a media
- why you don’t Implement PDO for access every thing to database
- SQL query to rewrite all media URLs to end with .webp
- Deleting WordPress posts and media files based on author via MYSQL database
- SQL errors when querying for something with apostrophes
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- Rename a table in MySQL
- How should I tackle –secure-file-priv in MySQL?
- Can’t connect to MySQL server on ‘127.0.0.1’ (10061) (2003)
- Error Code: 2013. Lost connection to MySQL server during query
- 1052: Column ‘id’ in field list is ambiguous
- 1052: Column ‘id’ in field list is ambiguous
- What SQL Query to do a simple find and replace
- Checking if Database Table exists
- How to fetch Data in WordPress using MySQLi or $wpdb
- Connect to database using wordpress wp-config file
- How To Export/Import WordPress (MySQL) Database Properly Via Command-Line?
- How to define composite keys with dbDelta()
- Is it possible to define two databases for one installation?
- “MySQL server has gone away” since update to 3.8
- Scheduling posts in database
- Emojis getting converted to “?”
- Query from a different database than the default
- Replace/Mute/Stop Search Query
- Migrating to WordPress Recipe Plugin and Some SQL Issues
- How to prevent/delay MySQL connections when an object cache is used?
- Migrating from PDO using SQLite to clean new install using MySQL
- $wpdb->insert Giving duplicates
- Which data is written and stored in the database when read-only (non-posting, non-commenting) users visit the site?
- Duplicated site isn’t recognized as a site
- Changing root password in PHPMyAdmin for WordPress Database when going live
- How to properly check if a table exists in WordPress Database using Show Tables Query
- How and where is wordpress adding mySQL content to database?
- Using AND and bracket grouping in SQL not working
- Is my way to change WordPress server is correct?
- How to delete a particular row in a database table
- Files on Localhost, Database on Server
- mySQL queries are executed twice on wordpress website
- Getting “Error Establishing a Database Connection” on localhost in new Mac OSX Lion environment
- custom tables in wordpress Database? (can i just create them with sql?)
- Accidently changed the GUID
- Replacing javascript link in WordPress database without getting mysql syntax errors
- how to access 2nd Mysqli Database from different server for wordpress
- Error establishing a database connection – WordPress setup, everything else is working
- Help posting values to DB on submit using $wpdb->query
- How to map data on CSV to web pages?
- Search and Replace in Windows XAMPP site
- The function is deprecated; use mysql_real_escape_string() instead
- How can i syn wordpress user table with a stand-alone php script?
- insert data from a form:: Warning Empty query mysqli::query()
- How to get specific table by current user login
- How can we speed up wp_get_nav_menu_items()?
- $wpdb not working
- WordPress Database Posts Table query
- Extracted CSV as Array for Custom Query Loop
- Hang Up Followed By Can’t select database
- Generating an HTML table from an array based on dynamic key values
- Mysql Queries per Visit – Crazy High
- How to make MySQL search queries with quotes
- WP_Query always returning the last custom post
- using same mysql user with many databases
- Why are my WordPress post queries so slow?
- Custom wordpress SQL statement for a website