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
 SQL Server Development (2000)
 Cursor

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-01-11 : 08:18:40
asah writes "I have two tables,one in which I have ipaddress and in other table a number range for range of ipaddress and country name.

In my program I get the 1000 ipaddress and another function I call a function with args ipaddress so it again hits the sql server 1000 times to get the country name.

example
function1:
select ipaddress from where date_from between 12/12/1005 and 14/12/2005;

while(resultset.next())
{
getCountryName(resultset.getString(ipaddress));
}

function 2:
getCountryName(ipaddress)
{
select country_name where ip=ipaddress;
}

I want to decrease no of hits to sql server."

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2006-01-11 : 08:53:26
Unfortunately, your only option will be to learn SQL and how to join two tables together. I recommend a good book on beginning SQL Server to learn the basics of a SELECT statement and JOINS. You are correct in recognizing that doing what you are doing in your application layer is a bad thing and really negates the powerful features of a RDBMS, so right off the bat you have a good understanding of how a client/server system works so I expect you should have no trouble learning SQL.

If you would like help generating your single SELECT statement, you'll need to provide us with your table structure, some sample data, and a detailed description of what you need and what logic should be applied so that we aren't trying to guess what you want.

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-01-12 : 03:27:52
As suggested, you need to use joins. Learn SQL

Start with these
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -