Real dificult SP ... is it even possible ?
From: Zwi2000 (zwi2000_at_hotmail.com)
Date: 07/20/04
- Next message: Louis Davidson: "Re: unable to return @@identity after insert - please help"
- Previous message: Henry: "Re: adjacency list model"
- Next in thread: Zwi2000: "Re: Real dificult SP ... is it even possible ?"
- Reply: Zwi2000: "Re: Real dificult SP ... is it even possible ?"
- Reply: Zwi2000: "Re: Real dificult SP ... is it even possible ?"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 19 Jul 2004 23:53:40 -0400
Hi,
I have been thinking and thinking how to do this query, but just cant think
of anything. Ill try to explain in steps.
I have two pages:
1) Page one is a search page that will pass on parameters to page two. I
will focus on parameters for "UserId", it passes either one integer (2), or
many depending on the user selection (2,5,18,2).
2) Page two should display the results and here is where the query is
needed.
This is the design of the tables.
1) Table one has "cases", each case has a unique ID. It could be as simple
as:
CaseID - Integer (Key)
CaseNumber - varchar
2) Table two links users to cases (Users is another table, at this point
doesnt matter)
LinkId - Integer (Key)
UserId - Integer (This links Users here)
CaseId - Integer (This is the key from table 1)
I need to display on page two all cases in which the selected users are
passed on from page # 1 (Could be one or more).
If I link both tables I will get only one user for each case, and the case
may be repeated. How do I display all users linked to one case in just one
results (one line). so that when checked against the parameters I get the
needed results.
Something like:
CaseId, UserId1 (Linked), UserId2 (Linked), UserId 4 (Linked), etc ....
I tried:
Select * from cases
Inner join users on cases.userid = users.userid
Problem: I get results like
CaseId = 1221
UserId = 3
CaseId = 1221
Userid =5
And so forth .. one line each, what I need is:
CaseId = 1221
UserId = 3,5 ...
That way I can run the desired query.
Any idea how to accomplish this ?
Thanks !
Z
- Next message: Louis Davidson: "Re: unable to return @@identity after insert - please help"
- Previous message: Henry: "Re: adjacency list model"
- Next in thread: Zwi2000: "Re: Real dificult SP ... is it even possible ?"
- Reply: Zwi2000: "Re: Real dificult SP ... is it even possible ?"
- Reply: Zwi2000: "Re: Real dificult SP ... is it even possible ?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|