[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.2

Problem with sql query

Asked by davlun20080 in MySQL Server

Tags: date_format, pr_type, problem, query

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.
[+][-]08/11/02 11:45 PM, ID: 7213620Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: MySQL Server
Tags: date_format, pr_type, problem, query
Sign Up Now!
Solution Provided By: angelIII
Participating Experts: 2
Solution Grade: B
 
[+][-]08/13/02 12:15 AM, ID: 7216362Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/13/02 02:16 PM, ID: 7218361Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/13/02 06:03 PM, ID: 7218727Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81