how to user inner join query in Distinct?

Posted by Chandru_ra under Sql Server on 7/7/2011 | Points: 10 | Views : 6176 | Status : [Member] | Replies : 5
Dear all,

"(select Distinct from F.forumID,F.Author,F.forumTitle,F.forumDesc,F.Category,F.Points,F.Images,F.Dateofpost,Convert(VARCHAR(10),F.Dateofpost,101) as Jdate) from tblForum) F inner join select * from tblForumResponse s on F.forumID=s.forumID where F.Status='Approved' order by s.Dateofpost desc

now am this query

Display in this error

Incorrect syntax near the keyword 'from'.
Incorrect syntax near the keyword 'on'.

Advance Thanks to all

chandru


Responses

Posted by: Lakn2 on: 7/7/2011 [Member] Starter | Points: 25

Up
0
Down
After inner join you can give only table name how can i give you select statement,remove select statement give tablename only

Thanks&Regards
LakshmiNarayana Nalluri.

Chandru_ra, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Chandru_ra on: 7/7/2011 [Member] Starter | Points: 25

Up
0
Down
hi,

am change the query
(select DISTINCT F.forumID,F.Author,F.forumTitle,F.forumDesc,F.Category,F.Points,F.Images,F.Dateofpost,Convert(VARCHAR(10),F.Dateofpost,101) as Jdate from tblForum F )join tblForumResponse s on F.forumID=s.forumID where F.Status='Approved' order by s.Dateofpost desc

but now only display in error

Incorrect syntax near the keyword 'join'.

chandru

Chandru_ra, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakn2 on: 7/7/2011 [Member] Starter | Points: 25

Up
0
Down
try this

select DISTINCT F.forumID,F.Author,F.forumTitle,F.forumDesc,F.Category,F.Points,F.Images,F.Dateofpost,Convert(VARCHAR(10),F.Dateofpost,101) as Jdate from tblForum F inner join tblForumResponse s on F.forumID=s.forumID where F.Status='Approved' order by s.Dateofpost desc



Thanks&Regards
LakshmiNarayana Nalluri.

Chandru_ra, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Chandru_ra on: 7/7/2011 [Member] Starter | Points: 25

Up
0
Down
hi,
now this error displayed

ORDER BY items must appear in the select list if SELECT DISTINCT is specified.


chandru

Chandru_ra, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 7/7/2011 [Member] Starter | Points: 25

Up
0
Down
Try to use any of these two
select DISTINCT F.forumID,F.Author,F.forumTitle,F.forumDesc,F.Category,F.Points,F.Images,F.Dateofpost,Convert(VARCHAR(10),F.Dateofpost,101) as Jdate 

from tblForum F inner join tblForumResponse s on F.forumID=s.forumID
where F.Status='Approved'
order by F.Dateofpost desc

or
select DISTINCT F.forumID,F.Author,F.forumTitle,F.forumDesc,F.Category,F.Points,F.Images,F.Dateofpost,Convert(VARCHAR(10),F.Dateofpost,101) as Jdate ,s.Dateofpost 

from tblForum F inner join tblForumResponse s on F.forumID=s.forumID
where F.Status='Approved'
order by s.Dateofpost desc


Chandru_ra, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response