views:

54

answers:

1

Hi,

So I am a first time user here, and still relatively new to SQL. I am attempting to take 2 tables, and join them in a sense.

In Table1 I have the data:

House_Key ---Other Fields---   Customer_ID

House_Key is not unique, and as such I can have multiple Customer_IDs per household. House_Key is a numerical code, and Customer_ID is either Home, Business, or Bulk.

In Table2 I have the House_Key field, but not the Customer_ID field.

My goal is to have a new table that holds the fields of Table2 with a field called Customer_ID, but instead of having a new row for each type of Customer_ID like in Table 1, I want to have each House_Key only have one row, and the Customer_ID say something like "Home Business Bulk" if it is all three or any combination of them, but would prefer that it always have Home before Business before Bulk in the field.

Is there any way to do this? Thank you very much ahead of time.

Also, not sure if it matters, but in case it does I'm using SQL Server 2005.

+5  A: 

Wow, I'm glad that you came here for an answer, but seems that you really need some reading about relational databases.

Instead of writing looong answer here're the links:

http://en.wikipedia.org/wiki/Database_normalization

http://en.wikipedia.org/wiki/Join_(SQL)

zarko.susnjar
beat me to it zarko
tQuarella
+1 Couldn't agree more.
Joe Stefanelli
I always hated when seniors sent wikipedia links to me, but it's short, examples are good and it's free. I hope Shavus doesn't find it offending.
zarko.susnjar
Thanks, reading through it now. I think a good 60% of my problem is I was giving an ACL script and told to convert it to SQL. So while I know only a little about SQL, I know nothing about ACL, and the logic is seemingly terribly different.