One more thing, if you want an example database of these relationships,
check out Northwind, which ships with SQL Server.
--
Tom
---------------------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com [quoted text, click to view] "Tom Moreau" <tom@dont.spam.me.cips.ca> wrote in message
news:Ohpxxo44EHA.2124@TK2MSFTNGP15.phx.gbl...
This is not the right way to go. Using the info you have provided, you
would have 3 tables:
Clients
ClientID
ClientName
Products
ProductID
ProductName
ClientProducts
ClientID
ProductID
Quantity
Thus, ClientProducts would have the list of all products bought by each
client. If you are interested in which clients have bought both products A
and B, try:
select
ClientID
from
ClientProducts
where
ProductID in ('A', 'B')
group by
ClientID
having
count (*) = 2
--
Tom
---------------------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com [quoted text, click to view] "Homer Fhardwhoster" <homer@fhardwhoster.com> wrote in message
news:uwBfXi44EHA.1300@TK2MSFTNGP14.phx.gbl...
I'm just starting out with SQL server and I am trying to understand the
following.
I have two tables, say "Clients" and "Products"
A client can buy one or more products so I want to have a "Products" field
in the clients table. which stores the list of products a client has bought.
How do I specify that and if I have a client how can I say that he has
product A and B?
--
Homer Fhardwhoster
"Get 'em while they're 'ot, they're lovely"