Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 lookup table

Author  Topic 

u2p_inst
Yak Posting Veteran

78 Posts

Posted - 2003-12-15 : 05:51:44
i have 2 tables
1st table:

id | max | min | value|
1 1 10 1
2 11 20 2
3 21 30 3

2nd table such

id| Number |
1 8
2 14
3 25

i need the result like

col1 | col2 | col3
1 8 1
2 14 2
3 25 3

is it possible?How?

oh

Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2003-12-15 : 06:26:38
It's not obvious from your question whether the values of col1 and col3 in the result are from Table1.id, Table1.Value or Table2.id.

Assuming col1 is from Table2.id and col3 from Table1.Value, and that you really meant your 'max' values to be smaller than your 'min' values:

SELECT Table2.id AS col1, Table2.Number AS col2, Table1.value AS col3
FROM Table2
INNER JOIN Table1 ON Table2.Number BETWEEN Table1."max" AND Table1."min"
Go to Top of Page

u2p_inst
Yak Posting Veteran

78 Posts

Posted - 2003-12-15 : 21:39:01
thx arnold you're script working properly, but i have additional question now if the 2nd table(table2) have additional field let say value so if i input data to table2 then the field(value) automaticly insert data from lookup table(table1) so the result like you're script
and value in table2 same with col3 in youre sql command

Thx

oh
Go to Top of Page

u2p_inst
Yak Posting Veteran

78 Posts

Posted - 2003-12-16 : 07:23:16
is possible to create the automation using trigger?
how?

oh
Go to Top of Page
   

- Advertisement -