473,395 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Querying data from multiple views

Hello,

I am relatively new to doing non-trivial SQL queries.

I have to get data out of 8 diff views based on a parameter Name.

There is a view having name-ssn pairs. All other views have SSN field.

For a person there MAY NOT be data in all the views.

I have to populate data into diff tables in a Report from different
views.

I would like to know what is the best way to approach it.

So far I was trying an Inner join from the Name-ssn vies to all other
views based on the SSN and test for the name field with the input
parameter.

I am thinking there will be problem of Cross join if I dont have data
in all views about a person.

Or the best way is to write query for each view and have all of them in
a stored procedure ?

Any help will be appreciated

Thanks
Bofo

Jul 23 '05 #1
1 1662
Win2003InstallIssues (bo******@yahoo.com) writes:
I am relatively new to doing non-trivial SQL queries.

I have to get data out of 8 diff views based on a parameter Name.

There is a view having name-ssn pairs. All other views have SSN field.

For a person there MAY NOT be data in all the views.

I have to populate data into diff tables in a Report from different
views.

I would like to know what is the best way to approach it.

So far I was trying an Inner join from the Name-ssn vies to all other
views based on the SSN and test for the name field with the input
parameter.

I am thinking there will be problem of Cross join if I dont have data
in all views about a person.

Or the best way is to write query for each view and have all of them in
a stored procedure ?


Your post is not that crystal clear. But it sounds to me that you
should left-join from the Name-SSN mapping view:

SELECT ...
FROM name_ssn_view n
LEFT JOIN ssn_view1 ON n.ssn = s1.ssn
LEFT JOIN ssn_view2 ON n.ssn = s2.ssn
...
WNERE n.name = @name

If this does not answer your question, please post some simplified
example that shows your setup.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Jerry Weinstein | last post by:
Hi, I know about stored procedures and that they can speed up data entry via the SQL 'insert ' statement. However, one drawback to this method is that using the stored procedure still requires...
2
by: Elliot Rodriguez | last post by:
As I continue to read more about the benefits of database querying using ADO.NET, I am having a more difficult time distinguishing what the best approach to data retrieval is anymore. When...
4
by: Alex | last post by:
Dear netters, We are looking to build a SQL Server database that will be hooked up to a Web server (WebLogic or a .NET). The database will house data for multiple customers, and the...
6
by: Greg | last post by:
I am working on a project that will have about 500,000 records in an XML document. This document will need to be queried with XPath, and records will need to be updated. I was thinking about...
3
by: KemperR | last post by:
Hello Experts outhere, may be someone can tell me whats going wrong with my ADOX trial. I have an Access 2002 database with some tables and queries (views) The code listed below works well up...
5
by: Shane | last post by:
I wonder if someone has any ideas about the following. I am currently producing some reports for a manufacturing company who work with metal. A finished part can contain multiple sub-parts to...
17
by: stathis gotsis | last post by:
Hello everyone, I am tying to come up with an elegant way to process some input data that come from a form. When the user hits the 'Submit' button, i want the form to appear again with the...
3
by: ~john | last post by:
I'm working on a multi-user system that at times may result in 2 users accessing the same screen. These screens allow the users to both view and update data. The problem comes when you have user A...
1
by: Bill Sexton | last post by:
I have created a custom DataSourceControl to interface to a search engine. The DataSourceControl exposes multiple views of the same data. The first is the actual search results. The other views...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.