请教一个left JOIN去除重复的问题
我原来的是
SELECT top 8 * from PE_Article left JOIN PE_Comment on PE_Comment.InfoID=PE_Article.ArticleID where ChannelID=1002 Order By ArticleID desc
可以查询出8条数据,但是会把有重复的也显示出来
PE_Article
中的ArticleID ChannelID ClassID Title TitleIntact Subheading Author CopyFrom Inputer LinkUrl Editor Keyword Hits CommentCount UpdateTime CreateTime OnTop Elite Status Content IncludePic DefaultPicUrl UploadFiles InfoPoint PaginationType Deleted SkinID TemplateID Stars TitleFontColor TitleFontType MaxCharPerPage ShowCommentLink Receive ReceiveUser Received AutoReceiveTime ReceiveType Intro PresentExp Copymoney IsPayed Beneficiary PayDate VoteID InfoPurview arrGroupID ChargeType PitchTime ReadTimes DividePercent BlogID
pe_comment
中是 CommentID ModuleType InfoID UserType UserName Sex OICQ MSN ICQ Email Homepage IP WriteTime Score Content ReplyName ReplyContent ReplyTime Passed
不知道高手们看的懂不,我是新手,让我整理太难了, InfoID中如果有重复数据的话,会显示重复数据,我觉得就是应该在PE_Comment.InfoID=PE_Article.ArticleID比较之前就把InfoID中重复的值去掉,请高手帮忙写个列子吧,access数据库
SELECT top 8 * from PE_Article left JOIN PE_Comment on PE_Comment.InfoID=PE_Article.ArticleID where ChannelID=1002 Order By ArticleID desc
可以查询出8条数据,但是会把有重复的也显示出来
PE_Article
中的ArticleID ChannelID ClassID Title TitleIntact Subheading Author CopyFrom Inputer LinkUrl Editor Keyword Hits CommentCount UpdateTime CreateTime OnTop Elite Status Content IncludePic DefaultPicUrl UploadFiles InfoPoint PaginationType Deleted SkinID TemplateID Stars TitleFontColor TitleFontType MaxCharPerPage ShowCommentLink Receive ReceiveUser Received AutoReceiveTime ReceiveType Intro PresentExp Copymoney IsPayed Beneficiary PayDate VoteID InfoPurview arrGroupID ChargeType PitchTime ReadTimes DividePercent BlogID
pe_comment
中是 CommentID ModuleType InfoID UserType UserName Sex OICQ MSN ICQ Email Homepage IP WriteTime Score Content ReplyName ReplyContent ReplyTime Passed
不知道高手们看的懂不,我是新手,让我整理太难了, InfoID中如果有重复数据的话,会显示重复数据,我觉得就是应该在PE_Comment.InfoID=PE_Article.ArticleID比较之前就把InfoID中重复的值去掉,请高手帮忙写个列子吧,access数据库
...全文
相关推荐
oracle-join用法
例如: ```sql SELECT * FROM t1 NATURAL JOIN t2; ``` 自然连接的结果会去除重复的字段,只保留一个"num"和"name"字段。5.
MySQL中union和join语句使用区别的辨析教程
`UNION ALL`与`UNION`类似,但它不会去除重复的行,所以结果集中可能会包含相同的行。
浅谈mysql中多表不关联查询的实现方法
UNION ALL会保留所有行,包括重复行,而UNION则会去除重复行。因此,如果你不关心重复数据,使用UNION ALL通常更高效,因为它不需要额外处理去除重复的步骤。
高级SQL查询语言(适合有基础的sql程序员)
Left Outer Join(左外连接): 它返回所有左表(前一个表)的记录,以及与右表(后一个表)匹配的记录。如果右表没有匹配项,则结果为NULL。
Which SQL statement is the trump card to the senior software developer
UNION会去除重复的行,而UNION ALL则包含所有行,包括重复的。它们在整合来自不同来源的数据,或者构建汇总视图时很有价值。


