Question
August 8, 2007 at 12:15 AM
shabana1128

help on joining two tables

by shabana1128 . Updated 18 years, 12 months ago

Hi,
I am new to SQL server.Working for SQL Server 2000.
I have two tables which are related twice
as my first table(master) is having a column named “KeyId” and
second table(child) is containing two columns AttrId ,Units# these two are foreign keys to the single column “KeyId” of first table(master).

I need to get the matching values of the two Columns from a single query which am unable to get.

The query which i used is

select Dic.AttrName as PropName, mat.AttrValue, mat.AttrMinValue, mat.AttrMaxValue,Dic.Category,Dic1.AttrName
from Materials mat, DictionaryTable Dic ,DictionaryTable Dic1
where mat.Rspec# =@p1 and
mat.Rev# =@p2 and
Dic.Category like @p3 and
mat.AttrId = Dic.KeyId and
mat.Units# = Dic1.KeyId

Pls suggest me a better approach how to join the two tables twice?…

thanks in advance..

shab

This discussion is locked

All Comments