zhenxin Posted August 2, 2007 Share Posted August 2, 2007 I want to select all threads even though the count(Messages.TitleID) is zero.. Is like when u start a new thread with no messages currently posted. How can i modify the codes to do it?SELECT Thread.ThreadTitle, COUNT(Messages.TitleID) AS NoOfMessage, Thread.ThreadID FROM (Thread INNER JOIN Messages ON Thread.ThreadID = Messages.ThreadID) GROUP BY Thread.ThreadTitle, Thread.ThreadID Link to comment Share on other sites More sharing options...
smartalco Posted August 2, 2007 Share Posted August 2, 2007 the best i can gather from your post your working on a forum and want to show threads with no posts in thembut, thats impossible, the threadstarter made a postcan you elaborate a little more? Link to comment Share on other sites More sharing options...
aspnetguy Posted August 2, 2007 Share Posted August 2, 2007 what is that query giving you? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 2, 2007 Share Posted August 2, 2007 You need to use a left outer join instead of an inner join. An inner join will only give you records that exist in both tables. If you do this:A left outer join BIt will give you all the rows in A (because it's on the left), and only the rows in B that match. If you do this:A right outer join BIt will give you all the rows in B (because it's on the right) and only the rows in A that match. Link to comment Share on other sites More sharing options...
zhenxin Posted August 3, 2007 Author Share Posted August 3, 2007 You need to use a left outer join instead of an inner join. An inner join will only give you records that exist in both tables. If you do this:A left outer join BIt will give you all the rows in A (because it's on the left), and only the rows in B that match. If you do this:A right outer join BIt will give you all the rows in B (because it's on the right) and only the rows in A that match.Thanks for your help.. ITs done.. I got another problemI need to delete the thread(parent class) which it will auto delete all messages(child class).How to modify the delete statement? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 3, 2007 Share Posted August 3, 2007 You have to use 2 delete statements. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.