Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A better way

Status
Not open for further replies.

ssv45324

Programmer
Mar 17, 2006
16
0
0
US
I have a view say peoplesearch which have columns say
name, description, age etc.(aggregate of a couple of tables)
. Now i have two other tables which will have the addresses of each person in the view peoplesearch. These tables are address and peopleaddress.

My goal is to retrieve the city, state, country, name, age of a person with minimum database calls in an effient manner. So which is a better way -
1. To include the city, state and country in the peoplesearch view.
2. Execute a SQL statement to retrieve the addresses after getting each person from the database.
 
The second option, I would guess joining your view to the address tables ensuring you join on indexed fields and the WHERE clause filters accordingly.

e.g.

SELECT ViewResults.*, Add.City, Add.State etc.
FROM
Address
INNER JOIN (SELECT [FieldList] From PeopleSearch
WHERE [My Where Conditions tp Filter Results) ViewResults
ON [Join Criteria between view and Address]


"I'm living so far beyond my income that we may almost be said to be living apart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top