Advertisement

09.12.2007 at 08:40PM PDT, ID: 22825335
[x]
Attachment Details

Complex SELECT query

Asked by SWRO in SQL Server 2005, MS SQL Server, SQL Query Syntax

Tags: select, complex, query, sql

Here's a SELECT query that I am having an issue with...

The 4 tables in question (and their fields and some basic input)

<TeamTable>
TeamID, TeamName, UserID
1,Alpha, Jane
1,Alpha, John
2,Beta,Cindy
3,Gamma,Tom
3,Gamma,Alice
3,Gamma,Betty

<ProjectsTable>
ProjectID, ProjectName, ProjectDescription
1,Upgrade, Upgrade to XP
2,Relocation, Move office
3,Website, Build new Intranet
4,Add Department, Add new department to Sales function

<ProjectMembersTable>
ProjectID, UserID
1,Jane
1,John
2,Tammy
3,Jack
4,Tom
4,Alice
4,Betty

<UsersTable>
UserID, UserName
John, John Doe
Tom, Tom Magnum
Alice, Alice Anderson
Betty, Betty Rubble

Here's the goal:
Have a user select a Team Name from a DropDownList on a web page. Pass TeamID to SQL and return output for all projects associated with that Team.

So, if they selected Team Gamma (ID of 3), the following Project should be returned: 4 (Add Department).

Pseduocode :Get Project(s) where everyone associated with a specific TeamID is also a member of the specified Project.

How is that written in T-SQL?
Start Free Trial
[+][-]09.12.2007 at 09:05PM PDT, ID: 19881607

View this solution now by starting your 7-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

Zones: SQL Server 2005, MS SQL Server, SQL Query Syntax
Tags: select, complex, query, sql
Sign Up Now!
Solution Provided By: Lowfatspread
Participating Experts: 4
Solution Grade: A
 
 
[+][-]09.12.2007 at 09:06PM PDT, ID: 19881611

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.12.2007 at 09:07PM PDT, ID: 19881614

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.12.2007 at 09:13PM PDT, ID: 19881634

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.13.2007 at 09:33AM PDT, ID: 19885097

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.13.2007 at 10:36AM PDT, ID: 19885596

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.14.2007 at 01:34AM PDT, ID: 19889741

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.14.2007 at 07:49AM PDT, ID: 19892022

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_1_20070628