I have a table 1 with the below columns
URL, ID
table 2 with
rang0 , range1 and value
ID column of table 1 will be in between range of table 2 range0 to range 1.
I need a result set of table 1 URL, ID and check the ID range in table 2 and get its corresponding value in table 2.
greatly appreciated if someone can send a query as example
Table 1 Data ID URL 10 google 11 yahoo 11 msn 12 google 13 yahoo 12 msn
Table 2
rangeo range 2 value 1 11 valu1 11 12 valu2 12 13 value3
The ID Column is not unique value, that means multiple ID's can fall in the same range in table 2
答案 0 :(得分:0)
This sounds like a simple join...
SELECT T1.URL, T1.ID, T2.Value
FROM Table1 as T1
INNER JOIN Table2 as T2 on T2.Range0 <= T1.ID and T2.Range1 >= T1.ID
This could join 1 row in Table1 to multiple rows in Table2. But you did not give enough information to know whether or not that is expected.
Check out this tutorial on SQL.