|
Posted by Erland Sommarskog on 03/08/06 12:21
Shwetabh (shwetabhgoel@gmail.com) writes:
> Table 3
>
> --------------------------------------------------------------------------
---------------------------------------------------
>| Part_num | Prt_name | Desc1 | Desc2 | Cat_num | Cat_name |
> SDsc1 | SDsc2 |
> --------------------------------------------------------------------------
---------------------------------------------------
>| PRT1 | PartA | abc | xyz |
> |
>| PRT2 | PartB | def | aaa |
> |
>| PRT3 | PartC | ghi | bbb |
> |
>| | | | | CAT1
> | CatalogA | abc | xyz |
>| | | | | CAT2
> | CatalogB | def | aaa |
>| | | | | CAT3
> | CatalogC | ghi | bbb |
> --------------------------------------------------------------------------
--------------------------------------------------
>
>
> The blanks in Table 3 are , well ,blank.
>
> Now can it be done or not?
Judging from the sample data you posted, what you want is
SELECT a.Part_num, a.Prt_name, a.Desc1, a.Desc2, b.Cat_num,
b.Cat_name, b.SDsc1, b.SDcs2
FROM table1 a
JOIN table2 b ON a.Desc1 = b.SDsc1
AND b.Desc2 = b.SDcs2
But I cannot say that it make much sense to join over a description column.
Maybe you need to consider a little more what you are actually looking
for and what you want to achieve.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
[Back to original message]
|