Ciao.
Non riesco a capire cosa c'è che non va in
questa query con la versione 5 di mysql
(con la versione MySQL 4.1.8 funziona)
la struttura del DB:
Codice PHP:
CREATE TABLE IF NOT EXISTS `categories` (
`category_ID` int(10) unsigned NOT NULL auto_increment,
`category_title` varchar(100) NOT NULL default '',
`category_description` text NOT NULL,
PRIMARY KEY (`category_ID`),
UNIQUE KEY `category_title` (`category_title`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `posts` (
`post_ID` int(10) unsigned NOT NULL auto_increment,
`category_ID` int(10) unsigned NOT NULL default '0',
`user_ID` int(10) unsigned NOT NULL default '0',
`post_title` text NOT NULL,
`post_preamble` text NOT NULL,
`post_content` longtext NOT NULL,
`post_date` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`post_ID`),
KEY `category_ID` (`category_ID`),
KEY `user_ID` (`user_ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `users` (
`user_ID` int(10) unsigned NOT NULL auto_increment,
`user_name` varchar(50) NOT NULL default '''0''',
PRIMARY KEY (`user_ID`),
KEY `user_name` (`user_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
e la query
Codice PHP:
SELECT c.category_title, p.category_ID, p.post_ID,
p.post_title, p.post_date, u.user_name FROM posts AS p
INNER JOIN categories AS c INNER JOIN users AS u ON
p.category_ID = c.category_ID ON p.user_ID = u.user_ID
ORDER BY p.post_ID DESC;