Hello All,
I have three tables I need to hook up in a query. The problem I am encountering is that it is not selecting all of the rows in the main table press_release as I progressivly add more joins.
Here are my tables:
CREATE TABLE `press_release` (
`pr_id` int(11) NOT NULL auto_increment,
`pr_type` int(11) NOT NULL default '0',
`pr_group` int(11) default NULL,
`pr_contact_1` int(11) NOT NULL default '0',
`pr_contact_2` int(11) default '0',
`pr_title` varchar(80) NOT NULL default '',
`pr_body_isHTML` tinyint(1) NOT NULL default '0',
`pr_body` text NOT NULL,
`pr_release_date` datetime NOT NULL default '0000-00-00 00:00:00',
`pr_expire_date` datetime NOT NULL default '0000-00-00 00:00:00',
`pr_create_by` int(11) NOT NULL default '0',
`pr_create_date` datetime NOT NULL default '0000-00-00 00:00:00',
`pr_modify_by` int(11) default NULL,
`pr_modify_date` datetime default NULL,
PRIMARY KEY (`pr_id`),
KEY `pr_contact_1` (`pr_contact_1`),
KEY `pr_contact_2` (`pr_contact_2`)
) TYPE=MyISAM
CREATE TABLE `contact` (
`contact_id` int(11) NOT NULL auto_increment,
`first_name` char(25) NOT NULL default '',
`last_name` char(25) NOT NULL default '',
`email` char(50) NOT NULL default '',
PRIMARY KEY (`contact_id`)
) TYPE=MyISAM
CREATE TABLE `press_release_group` (
`pr_group_id` int(11) NOT NULL auto_increment,
`pr_group_name` varchar(25) NOT NULL default '',
`pr_group_desc` varchar(255) default NULL,
PRIMARY KEY (`pr_group_id`)
) TYPE=MyISAM
Here is my query:
SELECT pr.pr_id,
DATE_FORMAT(pr.pr_release_
date,'%M %e, %Y') as date,
CONCAT(c1.first_name,' ', c1.last_name) as contact_name1,
CONCAT(c2.first_name,' ', c2.last_name) as contact_name2,
pr.pr_title,
pr.pr_body,
prg.pr_group_id,
prg.pr_group_name
FROM press_release as pr
INNER JOIN contact as c1
ON pr.pr_contact_1 = c1.contact_id
INNER JOIN contact as c2
ON pr.pr_contact_2 = c2.contact_id
INNER JOIN press_release_group as prg
ON pr.pr_group = prg.pr_group_id
;
I am trying to return all press releases with the names of the first and second contacts instead of their id's and the group name they belong to, instead of the id.
The problem is that it is filtering the results, only returning a portion of the rows. If i remove the joins to the contact table, it returns all the rows as expected.