Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MySQL Query

Posted on 2013-01-28
1
Medium Priority
?
154 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 2000 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

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…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

688 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