Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Test Question
Message
General information
Forum:
ASP.NET
Category:
Databases
Title:
Miscellaneous
Thread ID:
01454773
Message ID:
01454793
Views:
48
Sounds like a pretty typical many to many setup. Letters is the linking table with fks to both users and departments. So you just go in through the letters table, parameterizing on userid, and get letters.*, departments.* joining letters to departments.

Very much like a student registration app where you would say "Show me all the grades for Student X and the course info for each course where he has a grade "


>That's all I have. I got it from someone else. It's sort of vague.
>
>
>>It may help if you post create table statements and some input. Desired output will help as well.
>>
>>>Show 3 different ways to do the following:
>>>
>>>
>>>- Each department can have multiple users.
>>>- Each user can have multiple departments.
>>>- A letter belongs to a user and a department.
>>>
>>>Write a stored procedure that takes a UserID and returns all of the columns from
>>>the Department and Letter tables for each Letter for the UserID that was passed to
>>>the stored procedure.
>>>
>>>Here's one way that I came up with:
>>>
>>>
>>>
>>>CREATE PROCEDURE GetDeptLetters
>>>	@UserId		INT
>>>
>>>AS
>>>
>>>	SELECT d.*, l.*
>>>		FROM Departments d
>>>		JOIN Letters l ON l.DepartmentId = d.DepartmentId AND l.UserId = @UserId
>>>		WHERE d.DepartmentId = @UserId


Charles Hankey

Though a good deal is too strange to be believed, nothing is too strange to have happened.
- Thomas Hardy

Half the harm that is done in this world is due to people who want to feel important. They don't mean to do harm-- but the harm does not interest them. Or they do not see it, or they justify it because they are absorbed in the endless struggle to think well of themselves.

-- T. S. Eliot
Democracy is two wolves and a sheep voting on what to have for lunch.
Liberty is a well-armed sheep contesting the vote.
- Ben Franklin

Pardon him, Theodotus. He is a barbarian, and thinks that the customs of his tribe and island are the laws of nature.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform