PDA

View Full Version : outer inner join



fazzfarrell
12-08-2006, 04:24 PM
I have two tables
a:
CREATE TABLE `Message` (
`ID` int(11) NOT NULL auto_increment,
`DATE` varchar(255) default NULL,
`USERNAME` varchar(255) default NULL,
`EMAIL` varchar(255) default NULL,
`TITLE` varchar(255) default NULL,
`MESSAGE` text,
`BLOCKED` varchar(255) default NULL,
`MessID` text,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=67 DEFAULT CHARSET=latin1 AUTO_INCREMENT=67 ;

b:
CREATE TABLE `MessageR` (
`ReplyID` text NOT NULL,
`ID` int(11) NOT NULL auto_increment,
`DATE` varchar(255) default NULL,
`USERNAME` varchar(255) default NULL,
`EMAIL` varchar(255) default NULL,
`TITLE` varchar(255) default NULL,
`MESSAGE` text,
`BLOCKED` varchar(255) default NULL,
`MessID` text,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=70 DEFAULT CHARSET=latin1 AUTO_INCREMENT=70 ;


I want to join these table but I am have trouble, every one some one makes a post to Message table it automaticly creates the ID number.

This then displays all the information on the page, they click reply the answer goes in to database 'MessageR' and puts the 'ID' number from 'Message' into 'ReplyID' in MessageR'.

If I combine the two tables it only shows the data that ties up, I want to show all the data if it has had a rply or not.

ant one help!!!

harsh789
12-11-2006, 07:07 PM
try this query


SELECT * FROM Message a LEFT JOIN MessageR b ON (a.ID = b.ReplyID)