Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

joning tables

Posted on 2004-09-20
7
Medium Priority
?
254 Views
Last Modified: 2010-04-06
Hi

I am writing a stored proc and it has two select statements.

wht i need is how to combine the two tables that are returned from the two select statements and display the combined table in the datagrid. Both the select statment tables have same data types. and the statements are parameterized statements. so i am not able to use the 'View' in this context.

is there any other possible solution for this.

Thanks
sandeep
0
Comment
Question by:sandeep437
  • 2
  • 2
7 Comments
 
LVL 21

Expert Comment

by:MogalManic
ID: 12107645
What web language are you using?
0
 

Author Comment

by:sandeep437
ID: 12108012
SQL server 2000
0
 
LVL 21

Expert Comment

by:MogalManic
ID: 12108663
If the two tables are in the same database, you can just join the two tables with a select statement:

SELECT publishers.name, publishers.id, books.title
        FROM publishers INNER JOIN books ON publishers.id = books.publisher_id


The above SQL joins Publishers table with books table.
0
 
LVL 2

Accepted Solution

by:
variant7 earned 1000 total points
ID: 12110163
I think a UNION query will do the trick for you :

SELECT t1.field1 AS fld1, t1.field2 AS fld2 FROM table1 AS t1
UNION
SELECT t2.otherfield1 AS fld1, t2.otherfield2 AS fld2 FROM table2 AS t2
0
 

Author Comment

by:sandeep437
ID: 12111851
Hi Variant7

       yeah. UNION is working good in this situation.

thanks

sandeep
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question