Title: Database error in SQL syntax
Last modified: August 21, 2016

---

# Database error in SQL syntax

 *  [karmamack](https://wordpress.org/support/users/karmamack/)
 * (@karmamack)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/database-error-in-sql-syntax/)
 * Hello, I have an error in my WP database and I have no idea what this means –
   or how to repair it. Just hoping someone is able to please help, in language 
   that I can understand 🙂
    This was happening on WP 8.3 – I have upgraded to 3.9.1
   and still the same. Here is the error message – the error file is massive:
 *     ```
       WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 9 for query SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_author_email, comment_date_gmt, comment_approved, comment_type,comment_author_url,
   
       				SUBSTRING(comment_content,1,45) AS com_excerpt
   
       				FROM Nomd45_comments
   
       				LEFT OUTER JOIN Nomd45_posts ON (Nomd45_comments.comment_post_ID =
   
       				Nomd45_posts.ID)
   
       				WHERE comment_approved = '1' AND comment_type = '' AND
   
       				post_password = ''
   
       				ORDER BY comment_date_gmt DESC
   
       				LIMIT  made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/maxmag/single.php'), get_sidebar, locate_template, load_template, require_once('/themes/maxmag/sidebar.php'), dynamic_sidebar, call_user_func_array, WP_Widget->display_callback, maxmag_tabs_widget->widget
       ```
   

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Mark Ratledge](https://wordpress.org/support/users/songdogtech/)
 * (@songdogtech)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/database-error-in-sql-syntax/#post-4898968)
 * That’s an issue with your maxmag theme. You need to check with those developers
   to see if there is a fix or an update for WP 3.9.
 *  Thread Starter [karmamack](https://wordpress.org/support/users/karmamack/)
 * (@karmamack)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/database-error-in-sql-syntax/#post-4898969)
 * Gee, that was fast thank you! I will check with the theme people now. Although
   I have 2 sites using that theme and the other one is fine. All the same plugins,
   too.
 *  Thread Starter [karmamack](https://wordpress.org/support/users/karmamack/)
 * (@karmamack)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/database-error-in-sql-syntax/#post-4899221)
 * Me again, Theme Forest (max-mag) told me to <<<remove your installation of WordPress,
   re-install the latest version of WordPress and then install the latest version
   of the theme without installing any other plugins or making any changes>>>
 * But, how do I remove the WordPress installation without losing all the posts 
   etc? There are over 200 …
 *  [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * (@lorro)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/database-error-in-sql-syntax/#post-4899256)
 * The post content is not in the WordPress files, its in your MySql database. So
   you can replace the files but not the database.
 * Delete then replace your copies of all files except the wp-config.php file and
   the /wp-content/ directory with copies from a fresh WordPress download. This 
   will effectively replace all of your core files without damaging your content
   and settings. Some uploaders tend to be unreliable when overwriting files, so
   delete the original files before replacing them.
 * Keep wp-config.php because the settings in here link your new WordPress files
   your old database.
 * Keep the /wp-content/ directory because it contains your uploads.
 * Nevertheless, take a good backup before starting.
 *  Thread Starter [karmamack](https://wordpress.org/support/users/karmamack/)
 * (@karmamack)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/database-error-in-sql-syntax/#post-4899266)
 * OK, thank you for replying. But I am not understanding why to replace the WordPress
   files when it is the database that has the error.
    I think I need to find some
   help, this is way over my head.
 *  [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * (@lorro)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/database-error-in-sql-syntax/#post-4899272)
 * Its easy to make it worse if you are not confident. You can [post a WordPress job here](http://jobs.wordpress.net/).

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Database error in SQL syntax’ is closed to new replies.

## Tags

 * [Database Error](https://wordpress.org/support/topic-tag/database-error/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 3 participants
 * Last reply from: [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/database-error-in-sql-syntax/#post-4899272)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
