mysqldump throws: Unknown table ‘COLUMN_STATISTICS’ in information_schema (1109)

This is due to a new flag that is enabled by default in mysqldump 8. You can disable it by adding –column-statistics=0. The command will be something like: mysqldump –column-statistics=0 –host=<server> –user=<user> –password=<password> Check this link for more information. To disable column statistics by default, you can add [mysqldump] column-statistics=0 to a MySQL config file, … Read more

Getting Error Trying to Create Table

From MySQL reference: Permitted characters in unquoted identifiers: ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore) Extended: U+0080 .. U+FFFF Permitted characters in quoted identifiers include the full Unicode Basic Multilingual Plane (BMP), except U+0000: ASCII: U+0001 .. U+007F Extended: U+0080 .. U+FFFF ASCII NUL (U+0000) and supplementary characters (U+10000 and higher) are not … Read more

How to get INSERT errors from $wpdb?

To insert data you should use query() (documentation), get_var() method is for selecting data. If error is encountered, query() returns FALSE. query() This function returns an integer value indicating the number of rows affected/selected for SELECT, INSERT, DELETE, UPDATE, etc. For CREATE, ALTER, TRUNCATE and DROP SQL statements, (which affect whole tables instead of specific … Read more

WordPress insert query is not working : Showing no Error

There appears to be a syntax error on line 4. string is not quoted ↓ ↓ ↓ $sql = “CREATE TABLE IF NOT EXISTS ” . $wpdb->prefix.credofy_contact_form. ” ( Instead, I would recommend moving your table creation logic to a plugin and having it run off an installation hook. Below is an example: <?php /** … Read more

Update Custom Post Type Taxonomies with SQL

Why am I getting this error? Because the table wp_term_taxonomy does not have the column object_id. And the correct table that you should update is the wp_term_relationships table which does have the column object_id. See the WordPress database diagram and also the WordPress database description for more details. So your SQL query should be: UPDATE … Read more

Replace a character in all post titles and slugs

Slugs are saved in the very same table but in the post_name column. So your query would look like this: UPDATE wp_posts SET post_name = REPLACE(post_name, ‘m’ , ‘p’) WHERE post_type=”post” AND post_status=”publish”; By the way, I’d suggest you to use $wpdb->posts instead of just wp_posts ( then it would be compatible with different prefixes, … Read more

SQL syntax error. However, it works normally at phpmyadmin

) bracket missing in last condition. (i.e AND (b.meta_key = ‘usage_count’ AND b.meta_value=”0″”); ) $rowcount = $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->postmeta AS a, $wpdb->postmeta AS b WHERE a.post_id = b.post_id AND (a.meta_key = ‘customer_email’ AND a.meta_value LIKE ‘%[email protected]%’) AND (b.meta_key = ‘usage_count’ AND b.meta_value=”0″)”); echo $rowcount;