need help in query

  • I m using SQLServer2000, i have 2 tables: 1)Clients ClientCode int (PK) ClientName Description 2)ClientAddresses ClientAddressID ClientCode (FK) CountryName CityName FaxNo Address1 IsBaseAddress now if the client 1 has 3 address then this query returns 3 rows but the client table data is duplicated with the ClientAddressData, is this other way we returned only 1 table but client info comes 1 time and its Addresses comes 3 (as if it has 3 address). I want to return 1 table only. so tell me how i do this as my query duplicates the client data coz i have 3 address so for each address client data is duplicated (in this i have nvarchar and ntext fields alo so when i used distinct it gives me error as this not used with these db types.

    SELECT dbo.Clients.ClientCode, dbo.Clients.ClientName, dbo.Clients.Description, dbo.ClientAddresses.ClientAddressID, dbo.ClientAddresses.CountryName, dbo.ClientAddresses.CityName, dbo.ClientAddresses.FaxNo, dbo.ClientAddresses.Address1 FROM dbo.Clients INNER JOIN dbo.ClientAddresses ON dbo.Clients.ClientCode = dbo.ClientAddresses.ClientCode where ClientAddresses.isBaseAddress=1

  • Well, if there are 3 addresses for the client, your query will return the client data along with the 3 different addresses, but I would not consider this duplicate data.  Can you give an example of how you would want your results to look?

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply