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.
| Author |
Topic |
|
Jake Shelton
Yak Posting Veteran
74 Posts |
Posted - 2012-01-18 : 18:08:52
|
| Hi all, How do I get two result sets side by side (instead of merged as a Union would do) ? |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2012-01-18 : 18:18:03
|
| Hello Jake Shelton,This is essentially what a JOIN does. If you have joining fields then you can merge 2 or more results together using these fields as the joining conditions.HTH. |
 |
|
|
Jake Shelton
Yak Posting Veteran
74 Posts |
Posted - 2012-01-18 : 19:10:04
|
| I'll show you. Here are the two select statements, whose results I'd like to see in 4 adjacent columns, NOT 2 per :SELECT SUBSTRING(Name, 1, 20) AS ProductName, ListPriceFROM Production.ProductWHERE CAST(ListPrice AS int) LIKE '3%'SELECT SUBSTRING(Name, 1, 20) AS ProductName, ListPriceFROM Production.ProductWHERE ListPrice LIKE '3%' |
 |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2012-01-18 : 19:24:44
|
Thanks,Do these two result sets have a joining value? If So, then the query might look like the following form:SELECT a.field1, a.field2, b.field1, b.field2FROM tableA as a JOIN tableA as b ON b.id = a.idWHERE <filter conditions exist> If they do not have a relationship, then how would you wish to combine them?HTH. |
 |
|
|
Jake Shelton
Yak Posting Veteran
74 Posts |
Posted - 2012-01-19 : 04:55:58
|
| The way I already stated. I just want to see the results of the two separate Select statements side by side, IN SEPARATE ROWS, in the results pane (if possible). Not merged, not joined. Four separate columns, one for each column being selected. I can then decide later if they need a relational join of any kind (Inner, outer etc.)Ok, maybe this will help, here's how I want to see the result set column headers: ProductName, ListPrice ProductName, ListPrice |
 |
|
|
|
|
|
|
|