Subject: | I cannot use "union" in my query after I installed DBD-mysql-3.0002_1.tar.gz and DBI-1.48.tar.gz |
You have an error in your SQL syntax near '( SELECT cms_articles.*, cms_categories.title, cms_categories.flag, cms_categori' at line 2
================
QUERY:
================
my $query = "
( SELECT cms_articles.*, cms_categories.title, cms_categories.flag, cms_categories.titleShowMode, cms_categories.titleShowChars
FROM cms_articles LEFT JOIN cms_categories ON cms_categories.id = cms_articles.categoryId
WHERE cms_articles.approve != 0 AND cms_articles.del = 0 AND cms_categories.flag IN ('1','101','102','103','104','106') ORDER BY postTime DESC LIMIT 0,10 )
union
(SELECT cms_articles.*, cms_categories.title, cms_categories.flag, cms_categories.titleShowMode, cms_categories.titleShowChars
FROM cms_articles LEFT JOIN cms_categories ON cms_categories.id = cms_articles.categoryId
WHERE cms_articles.approve != 0 AND cms_articles.del = 0 AND cms_categories.flag='105' ORDER BY postTime DESC LIMIT 0,10)
union
(SELECT cms_articles.*, cms_categories.title, cms_categories.flag, cms_categories.titleShowMode, cms_categories.titleShowChars
FROM cms_articles LEFT JOIN cms_categories ON cms_categories.id = cms_articles.categoryId
WHERE cms_articles.approve != 0 AND cms_articles.del = 0 AND cms_categories.flag='107' ORDER BY postTime DESC LIMIT 0,2)
union
(SELECT cms_articles.*, cms_categories.title, cms_categories.flag, cms_categories.titleShowMode, cms_categories.titleShowChars
FROM cms_articles LEFT JOIN cms_categories ON cms_categories.id = cms_articles.categoryId
WHERE cms_articles.approve != 0 AND cms_articles.del = 0 AND cms_categories.flag IN (2,201,202) ORDER BY postTime DESC LIMIT 0,10)
";
my $sth = query($query);
my $informations = $sth->fetchall_arrayref({});
$sth->finish;