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 |
|
shapper
Constraint Violating Yak Guru
450 Posts |
Posted - 2007-04-03 : 09:58:39
|
| Hello,I have the following tables:[Blogs] > BlogId (PK), ...[Posts] > PostId (PK), BlogId (FK), Title, Content, ...[Labels] > LabelId (PK), LabelName[LabelsInPosts] > LabelId (PK), PostId(PK)I am selecting all posts from a Blog given the BlogId:SELECT * FROM dbo.Posts WHERE BlogId = @BlogIdThis will return the columns Title, Content, ... for those posts.I would like to add 2 columns, PostLabels and LabelsCount:1. PostLabels would be created by: For each post select all the labels associated with it in LabelsInPosts. Then for each label get the label name. Then create the value of PostLabels which would be each label separated by a comma.2. LabelsCount would be the number of labels associated with each post I created a procedure which, given a PostId, returns the number of labels associated with it. So I suppose it would be only a question of integrating a call to this procedure with this SELECT I am trying to create.Thank You,Miguel |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-03 : 10:21:13
|
| We have asked you repeatedly to supply sample data and expected output.It you are not satisfied with our previous suggestion, try to help help! Give us more information.Post sample data and your expected outout.Until you do this for us, you might get anyhelp at all.For myself, I am pretty tired of you posting same problem over and over again.Peter LarssonHelsingborg, Sweden |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2007-04-03 : 11:53:18
|
Shooting for that 10k today Brett? [Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
shapper
Constraint Violating Yak Guru
450 Posts |
Posted - 2007-04-03 : 11:53:41
|
| Hi,Nothing is wrong with your previous answers. I used all the help code I got and I appreciate it.----This post could resume to just a simple question based on:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81486How to find the LabelIds in LabelsInPosts and then for each one get the LabelName from LabelsNames.Yes, I know what I should use Inner Join but I am having problems in integrating it in the code you told me on this post.---I don't post the query output because I haven't being able to pull the code right. I believe most of my questions are basic for experienced SQL programmers but the solution is really not obviously to me.I am on the other end of the rope, here. I understand your critics.I am an engineer and most of my work is in Neural Networks, Optimization, .NET/C. Even if something is obvious or easy to me in those areas it does not mean that it should be or is easy and obvious to others.When I post here it is really because I am not getting there.Anyway, it is not for post count. Thank You Anyway,Miguel |
 |
|
|
|
|
|
|
|