Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query problem

Status
Not open for further replies.

genxiii

Technical User
Jun 13, 2003
17
US
hey guys, i'm having a problem with a query that i need help.

first off i have 2 tables (1 to many relationship). I'm running the query from parameters on a form. Here's my problem.

when i run the query, since its a 1 to many relationship, some of the records are duplicates except for the foreign key. Is there a way i can eliminate this duplication and group all of those foreign keys together when i display it on a form?
 
Huh? How can you group different things together? Or do you mean group _by_ the FK? See my sig below for how to get better answers...

Jeremy

==
Jeremy Wallace
AlphaBet City Dataworks
Affordable Development, Professionally Done

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
yeah, sorry for the difficulty on my explanation. I jus didn't know how to put it into words. let me guess jus show what i have now and what i'm looking for.

Table1 Table2
P_ID ProjectName P_ID L_ID
---- ----------- ----------
P1 Project1 P1 L1
P2 Project2 P1 L2
P2 L2

those are my tables. when i run a query with the following SQL

SELECT ActionItem.ActionID, ActionItem.ActionItem, ActionItemLead.LeadID
FROM ActionItem INNER JOIN ActionItemLead ON ActionItem.ActionID = ActionItemLead.ActionID;

i get the results:

Query1
P_ID ProjectName L_ID
----- ------------ -----
P1 Project1 L1
P1 Project1 L2
P2 Project2 L2

notice how the the record P! appears twice, jus with a different L_ID for both of the entries. how can i combine those to make it just one entry?

i want it to be something like this

P_ID ProjectName L_ID
---- ----------- -----
P1 Project1 L1, L2
P2 Project2 L2

is that possible?

sorry for explaining it the way i did. i'm not very good with this stuff or the terms.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top