A Database Error Occurred

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '`documents_tags`.`tag_id` IN ('12')) ORDER BY startdate DESC LIMIT 10' at line 16

SELECT `documents`.*, `documenttypes`.`name` as `doctype`, `articles`.`id` as `article_id`, `articles`.`language_id`, `articles`.`title`, `articles`.`template`, `articles`.`slug`, `articles`.`path`, `articles`.`slug_title`,`documents_tags`.`tag_id` FROM (`documents`) LEFT JOIN `articles` ON `articles`.`document_id` = `documents`.`id` LEFT JOIN `documents_tags` ON `documents`.`id` = `documents_tags`.`document_id` LEFT JOIN `documenttypes` ON `documents`.`documenttype_id` = `documenttypes`.`id` LEFT JOIN `documents_users` AS du ON `documents`.`id` = du.`document_id` LEFT JOIN `documents_usergroups` AS dug ON `documents`.`id` = dug.`document_id` WHERE `documents`.`trashed` = 0 AND `documents`.`published` = 1 AND `articles`.`status_id` = 1 AND `articles`.`language_id` = 1 AND ( (dug.usergroup_id IS NULL) AND (du.user_id IS NULL) ) AND (`documents`.`startdate` < NOW() OR `documents`.`startdate` = '0000-00-00 00:00:00' OR `documents`.`startdate` IS NULL) AND (`documents`.`enddate` > NOW() OR `documents`.`enddate` = '0000-00-00 00:00:00' OR `documents`.`enddate` IS NULL) AND (`documents`.`document_id` = 6`documents_tags`.`tag_id` IN ('12')) ORDER BY startdate DESC LIMIT 10