Question Locked

help on joining two tables

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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

2 replies

by tony hopkinson

as in joining twice using aliases dic and dic1.

Can't tell from what you've posted
but the thing that stands out for me is the lack of
Dic1.Category like @p3.

This discussion is closed to new replies.