Zargo
Programmer
- Mar 21, 2005
- 109
Hi all,
I have an huge table called link with the following content:
company account Codestart Codeend
100 515055 U UZZZZZ
100 515055 KG1L KG1L
100 515055 KGINT KGINT
100 515055 KG1A KG1A
100 515055 LG1 LG5
100 515055 800000 899999
100 515055 900000 999999
And i have an Codes table with the following content(example)
Code
1123
U1
LG4
ZG
845000
Z03
-----------------
I want to select all codes from the codes table for account 515055. Must check the Link table to check which codes i can use for account 515055. So the result must be(in our example):
U1
LG4
845000
I have tried a query like:
select code from codes where code >=
(SELECT codestart from link where account = '515055')
AND code <=
(SELECT codeend from link where account = '515055')
I couldnt use this because i have more values in the link table. How can i smartly build this query?
I have a possiblity to change the content of the tables(adding extra column to make it easier?!, changing the data?)
Who can give me the golden answer? A big star for the solution.
Thanks in advance.
Zargo
I have an huge table called link with the following content:
company account Codestart Codeend
100 515055 U UZZZZZ
100 515055 KG1L KG1L
100 515055 KGINT KGINT
100 515055 KG1A KG1A
100 515055 LG1 LG5
100 515055 800000 899999
100 515055 900000 999999
And i have an Codes table with the following content(example)
Code
1123
U1
LG4
ZG
845000
Z03
-----------------
I want to select all codes from the codes table for account 515055. Must check the Link table to check which codes i can use for account 515055. So the result must be(in our example):
U1
LG4
845000
I have tried a query like:
select code from codes where code >=
(SELECT codestart from link where account = '515055')
AND code <=
(SELECT codeend from link where account = '515055')
I couldnt use this because i have more values in the link table. How can i smartly build this query?
I have a possiblity to change the content of the tables(adding extra column to make it easier?!, changing the data?)
Who can give me the golden answer? A big star for the solution.
Thanks in advance.
Zargo