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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Joining multiple queries with different requirements

Status
Not open for further replies.

questhaven

Programmer
Mar 28, 2001
81
US
If I have 9 queries, six of which are looking for the same fields within the same 3 tables and three that only require information out of one of the 3 tables, and can not be joined with the remaining 2 tables, what would be the best way of going about this? Would I select everything into a temp table and use that for mining the data?

Thanks for any help!

- Michele
 
I figured it out. In case anyone has this same question, what I did was alias the column names in the 6 queries that have extra data (only 2 columns each) and then in the 3 other queries I assigned dummy values to these alias names - then unioned all of the queries together in one stored procedure.
 
You couldn't have said it better..


create stored procedure foo as

select t.(list of columns, , ,) from table t
UNION
select t.(list of columns, , ,) from table t
UNION

etc...

andy
 
Actually Andy - I think the way I said it is just fine...but thanks for your further clarification.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top