Click here to Skip to main content
15,923,273 members
Home / Discussions / Database
   

Database

 
GeneralArray Question Pin
Robby7-Jan-03 3:24
Robby7-Jan-03 3:24 
GeneralGetting 'Invalid RESX input' Pin
garfild6-Jan-03 22:21
garfild6-Jan-03 22:21 
GeneralRe: Getting 'Invalid RESX input' Pin
leppie7-Jan-03 6:14
leppie7-Jan-03 6:14 
GeneralADO at Startup Pin
fordge6-Jan-03 21:17
fordge6-Jan-03 21:17 
GeneralRe: ADO at Startup Pin
perlmunger7-Jan-03 5:50
perlmunger7-Jan-03 5:50 
GeneralRe: ADO at Startup Pin
fordge7-Jan-03 12:42
fordge7-Jan-03 12:42 
GeneralRe: ADO at Startup Pin
fordge22-Jan-03 15:22
fordge22-Jan-03 15:22 
GeneralDistinct Row Problem Pin
perlmunger6-Jan-03 13:28
perlmunger6-Jan-03 13:28 
I am doing a join with three tables and I can't seem to get distinct rows. I know what the problem is, but I'm not enough of a SQL person to know the proper syntax. The tables are Customers, CustomerRelationships, CustomerRelationshipsLU (as in Look Up). I get the CustomerID, FirstName, and Last Name from the Customers Table. The CustomerRelationships table tells me how one customer is related to another (e.g. wife, son, etc.). I need to get the name of the relationship and not the ID which is why I am joining the CustomerRelationshipsLU table as well. Here is the statement I am using currently:

SELECT TA_Customer.Customer_ID,
       TA_Customer.FirstName,
       TA_Customer.LastCompanyName,
       TA_CustomerRelationshipsLU.Description
FROM   TA_CustomerRelationships INNER JOIN TA_CustomerRelationshipsLU ON
       TA_CustomerRelationships.RelationshipID =
       TA_CustomerRelationshipsLU.RelationshipID CROSS JOIN
       TA_Customer
WHERE  (TA_Customer.CustomerID = '101') AND (TA_CustomerRelationships.CustomerID = '101')

Youre eyes are not deceiving you--there is a CustomerID and a Customer_ID (notice the underscore _ in the second). CustomerID represents what you might think of as a customer group (e.g. family, business, etc.) whereas Customer_ID represents the individual ID for every customer--as in person.

My query returns:

155611 Jane Jones Wife
155611 Jane Jones Son
155612 Willy Jones Wife
155612 Willy Jones Son

DISTINCT doesn't help for obvious reasons. Does this make sense to anyone? Any help would be appreciated.

-Matt

------------------------------------------

The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
GeneralRe: Distinct Row Problem Pin
l a u r e n6-Jan-03 13:35
l a u r e n6-Jan-03 13:35 
GeneralRe: Distinct Row Problem Pin
perlmunger6-Jan-03 13:46
perlmunger6-Jan-03 13:46 
GeneralRe: Distinct Row Problem Pin
l a u r e n6-Jan-03 14:40
l a u r e n6-Jan-03 14:40 
GeneralRe: Distinct Row Problem Pin
perlmunger6-Jan-03 18:34
perlmunger6-Jan-03 18:34 
GeneralRe: Distinct Row Problem Pin
Jeremy Oldham7-Jan-03 1:20
Jeremy Oldham7-Jan-03 1:20 
GeneralRe: Distinct Row Problem Pin
perlmunger7-Jan-03 5:38
perlmunger7-Jan-03 5:38 
GeneralRe: Distinct Row Problem Pin
Jeremy Oldham7-Jan-03 6:11
Jeremy Oldham7-Jan-03 6:11 
GeneralRe: Distinct Row Problem Pin
perlmunger7-Jan-03 6:23
perlmunger7-Jan-03 6:23 
GeneralRe: Distinct Row Problem Pin
Jeremy Oldham7-Jan-03 6:55
Jeremy Oldham7-Jan-03 6:55 
GeneralInserting a row and retreiving the Identity value Pin
moredip6-Jan-03 12:47
moredip6-Jan-03 12:47 
GeneralRe: Inserting a row and retreiving the Identity value Pin
l a u r e n6-Jan-03 13:38
l a u r e n6-Jan-03 13:38 
GeneralRe: Inserting a row and retreiving the Identity value Pin
moredip6-Jan-03 15:12
moredip6-Jan-03 15:12 
GeneralRe: Inserting a row and retreiving the Identity value Pin
Paul Riley6-Jan-03 14:52
Paul Riley6-Jan-03 14:52 
GeneralRe: Inserting a row and retreiving the Identity value Pin
moredip6-Jan-03 15:16
moredip6-Jan-03 15:16 
GeneralSOLUTION Re: Inserting a row and retreiving the Identity value Pin
moredip7-Jan-03 8:18
moredip7-Jan-03 8:18 
QuestionUnmanaged ADO.NET? Pin
clintsinger6-Jan-03 12:32
clintsinger6-Jan-03 12:32 
GeneralSQL Connection Problem! Pin
dyerstein6-Jan-03 5:58
dyerstein6-Jan-03 5:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.