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 |
|
spider3
Starting Member
11 Posts |
Posted - 2007-06-26 : 07:37:09
|
| Hi Everyone, I've created a small exmaple database. The tables are:TABLE CocktailsCocktailID (int, PK)CocktailName (varchar)CocktailDescription (varchar)TABLE IngredientsIngredientID (int, PK)IngredientName (varchar)TABLE CocktailIngredientsCocktailID (int, PK)IngredientID (int, PK)QuantityNeededIn this way, i can perform a query like:SELECT Cocktails.CocktailName, CocktailIngredients.CocktailIngredientQuantity, Ingredients.IngredientName, Cocktails.CocktailDescriptionFROM CocktailIngredients INNER JOIN Cocktails ON CocktailIngredients.CocktailID = Cocktails.CocktailID INNER JOIN Ingredients ON CocktailIngredients.IngredientID = Ingredients.IngredientIDAs result, I obtain the data I needed, like:MyCocktail1 2dl Rum DescrptionOfMyCocktailMyCocktail1 1dl Gin DescrptionOfMyCocktailMyCocktail1 2st Lemons DescrptionOfMyCocktailMyCocktail2 1dl Rum DescrptionOfMyCocktail...The name "MyCocktail1" and "DescrptionOfMyCocktail" is repeated every row, and I've been asked to find a way to avoid getting back a table with information I need only one time.Is there something wrong in the structure of my tables? Or there is a way to perform the query in a different way and have empty fields after the first description? (of course it will be written again if cocktail name changes)thank you a lot! |
|
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2007-06-26 : 09:50:14
|
| Your query is fine and works exactly the way it should. Each row is atomic, and SQL Server is not going to return partial data for a record.The job of hiding repeated values is a task for your presentation/reporting application (Crystal reports, MS Access, SQL Server Reporting Services, ASP, whatever...).e4 d5 xd5 Nf6 |
 |
|
|
spider3
Starting Member
11 Posts |
Posted - 2007-06-26 : 10:19:17
|
| Exacly as I thought ^^ thanks a lot for your confirmation! |
 |
|
|
|
|
|
|
|