Solved

MySQL Query

Posted on 2013-01-28
1
152 Views
Last Modified: 2013-01-28
This query correctly returns 94 rows of data...

SELECT pj.pname 'Project Name'
FROM project pj
WHERE pj.deleted = 'N'
AND pj.pstatus = 'Active'
ORDER BY pj.project_num;

I added a column to the query from the budget table and now I get a Carterian Pordect or 521 rows, even with a valid join condition.

SELECT pj.pname 'Project Name', bu.capital_id 'CAP'
FROM project pj
LEFT JOIN budget bu ON (bu.project_id = pj.project_id)
WHERE pj.deleted = 'N'
AND pj.pstatus = 'Active'
ORDER BY pj.project_num;
0
Comment
Question by:hdcowboyaz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 10

Accepted Solution

by:
deviprasadg earned 500 total points
ID: 38829885
Looks like there are multiple records in budget table for each project_id.

In such a case if you need a maximum or minimum or Avg etc..
You need to add a group by on pj.pname

Refer: http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question