dear r937,
it doesn't work and I am trying it since two hours.. it doesn't show any error message and 20 minutes waiting for the result, but there are no results and I just hear voice CPU works hard, but nothing happened.
on database more than 1000 records on news table and 8 records on category table. and it should work maximum in just few second time to get the results, but doesn't.
now I am putting here all code about news website, can you take a look please?
I just need two records from every single category in this query
Code:
SELECT parentcategory.categoryname as parentcategoryname, newscategory.categoryname as categoryname, newscategory.parentcategoryid, news.* from (newscategory right join news on newscategory.categoryid = news.categoryid) left join newscategory as parentcategory on newscategory.parentcategoryid = parentcategory.categoryid WHERE news.activated = 'True' order by news.newsdate desc LIMIT 20;
Code:
DROP TABLE IF EXISTS `news`;
CREATE TABLE "news" (
"CategoryID" int(11) NOT NULL,
"InternalID" int(11) NOT NULL,
"ItemID" varchar(30) collate utf8_unicode_ci NOT NULL,
"Name" varchar(255) collate utf8_unicode_ci default NULL,
"Memo" longtext collate utf8_unicode_ci,
"Picture" varchar(255) collate utf8_unicode_ci default NULL,
"Activated" varchar(5) collate utf8_unicode_ci default NULL,
"DateAdded" datetime default NULL,
"ExpiryDate" datetime default NULL,
"SortOrder" int(11) default NULL,
"Readed" int(11) default NULL,
"AdminNote" mediumtext collate utf8_unicode_ci,
PRIMARY KEY ("ItemID"),
UNIQUE KEY "InternalID" ("InternalID"),
KEY "CategoryID" ("CategoryID"),
CONSTRAINT "CategoryFK" FOREIGN KEY ("CategoryID") REFERENCES "newscategory" ("CategoryID") ON UPDATE CASCADE
);
-- ----------------------------
-- Table structure for newscat
-- ----------------------------
DROP TABLE IF EXISTS `newscategory`;
CREATE TABLE "newscategory" (
"ParentCategoryID" int(11) default NULL,
"CategoryID" int(11) NOT NULL,
"CategoryValue" varchar(50) collate utf8_unicode_ci default NULL,
"CategoryDesc" varchar(255) collate utf8_unicode_ci default NULL,
"CategoryLabel" varchar(50) collate utf8_unicode_ci default NULL,
"CategoryImageFile" varchar(50) collate utf8_unicode_ci default NULL,
"Activated" varchar(5) collate utf8_unicode_ci default NULL,
"SortOrder" int(11) default NULL,
PRIMARY KEY ("CategoryID"),
UNIQUE KEY "CategoryID" ("CategoryID"),
KEY "ParentCategoryID" ("ParentCategoryID")
);
Bookmarks