Table1:
This is the table1 data it having IPNumber. It contain 50,000 Records.
Table2:
This is table2 data it having below columns like ip_from & ip_to. This table contain 2023184Recs.
Query:
I want to get the data from Table1 and Table2 based on condition that is IPNumber from Table1 check range
between Table2 ip_from, ip_to columns. How to get the data from above two table.
Please give any idea for above issue.
Anupam SinghPosted May 31, 2014, 3:40 AM
not sure but will try.
SWAROOP PPosted May 31, 2014, 3:28 AM
Anupam SinghPosted May 31, 2014, 2:28 AM
how ever you can try below query for faster processing :
SELECT Table_1.name,Table_2.address from Table_1 with(nolock),Table_2 with(nolock) where Table_1.IPno between Table_2.ipfrm and Table_2.ipto
Jayakumar BalasubramaniamPosted May 31, 2014, 1:55 AM
SWAROOP PPosted May 30, 2014, 10:01 PM
ya. your query working fine but it takes lot of time bcz 2nd table having 2million records. Is there any way to write other than between?
Present in my db have above mention records but day by day it will be increased.
Jayakumar BalasubramaniamPosted May 30, 2014, 5:57 AM
Here i give you an example. verify it.
This is Table 1
This is Table 2
Query is:
SELECT Table_1.name,Table_2.address from Table_1,Table_2 where Table_1.IPno between Table_2.ipfrm and Table_2.ipto
This output :
If u got correct answer please let me know :)