Ever received a large MySQL dump file and only needed one table out of it? I ran across just this issue. The full database took significant time to import and I only needed a small subsection of the DB, just one single table. Rather than waiting for it all to import, I pulled together a
Find total number of post records on a WordPress Multisite in MySQL
I was recently asked for the total number of posts on a WordPress website. Normally as simple as looking at the number in the dashboard, however in this instance the WordPress install was a Multisite with nearly 100 sites. That would have taken far too long to do manually, but what about having MySQL do
Find and update WordPress posts with comments older than NNN days
I have a use case where I need to disable comments on posts in WordPress where the last comment was more than one year, or 365 days, ago. Posts can be found with this query: SELECT p.ID, p.post_title, p.post_date, p.comment_status, p.`ping_status` FROM wp_posts AS p WHERE p.ID IN ( SELECT c.comment_post_ID FROM wp_comments AS c
MySQL: Count number of tables in database
If you need to count the number of tables that exist in a MySQL database you can do so with the following query. Just remember to swap out the database name! SELECT count(*) FROM information_schema.tables WHERE table_schema = ‘YOUR_DB_NAME’
MySQL: Find the size of a database
MySQL has the ability to show you size of the information contained in your database. You can find this information per database or per table in a database pretty easily. Size of databases To list the size of all the databases on the server run the following: SELECT table_schema “Database”, sum( data_length + index_length) /