Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    outer inner join

    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!!!

  • #2
    Regular Coder
    Join Date
    May 2006
    Posts
    101
    Thanks
    0
    Thanked 1 Time in 1 Post
    try this query

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •