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 |
|
label
Posting Yak Master
197 Posts |
Posted - 2003-08-21 : 15:43:13
|
I have the following query:select heading, productIDfrom smc_new_products.dbo.marketingnewproductproductswhere productweek=1union select heading, productIDfrom smc_new_products.dbo.marketingnewproductproductswhere featuredProduct=1 That currently returns results like this:EVS7 | 140SV1000/2000 | 88 What I want, instead, is to return both results in one row. How do I flatten the current result which is two rows into 1 ? Thanks! |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-08-21 : 15:46:04
|
| This will still give you two rows, but it eliminates the union:select heading, productIDfrom smc_new_products.dbo.marketingnewproductproductswhere productweek = 1 or featuredProduct = 1How would you like the result set to look when combined into one row?Tara |
 |
|
|
label
Posting Yak Master
197 Posts |
Posted - 2003-08-21 : 15:53:59
|
quote: Originally posted by tdugganHow would you like the result set to look when combined into one row?
Product Header 1 | ProductID 1 | Featured Header 2 | FeaturedIDIt'll save me having to loop through the results when I'm populating the labels on my web page. Thanks. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-08-21 : 16:06:06
|
| Check out this article:[url]http://www.sqlteam.com/item.asp?ItemID=11021[/url]Just remove the comma from the query. The part that you are interested in is at the bottom.Tara |
 |
|
|
|
|
|