Query/Table help please!

wxdqz

New Member
Hi,

I am having problems with this query in PostgreSQL:

SELECT news.id, news.headline, news.summary, news.news, news.author,
news.date, categories.image, categories.cat_name
FROM news, categories
WHERE news.cat_id = categories.cat_id AND news.approved = 1
ORDER BY news.date DESC

The query executes sucessfully, but does not return any rows. It does however work on MySQL, which has led me to believe that it is really a problem with my tables, shown below:

/* --------------------------------------------------------
Table structure for table "categories"
-------------------------------------------------------- */
CREATE TABLE "categories" (
"cat_id" SERIAL NOT NULL PRIMARY KEY,
"cat_name" varchar(150) NOT NULL,
"cat_desc" text,
"image" varchar(100),
"active" char(1) DEFAULT '1' NOT NULL);
CREATE INDEX "cat_id_categories_key" ON "categories" ("cat_id");


/* --------------------------------------------------------
Table structure for table "news"
-------------------------------------------------------- */
CREATE TABLE "news" (
"id" SERIAL NOT NULL PRIMARY KEY,
"cat_id" char(3) DEFAULT '0' NOT NULL,
"headline" varchar(150) NOT NULL,
"summary" text NOT NULL,
"news" text,
"author" varchar(100) NOT NULL,
"email" varchar(40) NOT NULL,
"date" varchar(14),
"image" varchar(150),
"miniature" char(1) DEFAULT '0' NOT NULL,
"approved" char(1) DEFAULT '0' NOT NULL
);
CREATE UNIQUE INDEX "news_id_key" ON "news" ("id");


These were converted as best I could from MySQL ones, which work well :-)

Any help/advice much appreciated!
Peter.
 
Back
Top