Solved

MySQL Query

Posted on 2013-01-28
1
151 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
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

713 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