请问我如何让这些代码行运行无错误

jc3wubiy  于 2021-06-21  发布在  Mysql
关注(0)|答案(1)|浏览(330)

我总是犯这个错误 " The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator" 在sql上运行这行代码时--我希望获得的姓名,文本和最后的作者考虑他们最近的作品。

Select PR1.Name, PR1.TText, PR1.Author as Last_Author 
From PageRevision as PR1, PageRevision as PR2 
Group by Pr1.Name, PR1.TText 
Having PR1.DDate = max(PR2.DDate);
lhcgjxsq

lhcgjxsq1#

看来最简单的方法就是这么做。

Select PR1.Name, PR1.TText, PR1.Author as Last_Author 
From PageRevision as PR1
inner join (
Select name, ttext,author
        ,max(ddate) ddate
        From Pagerevision
        group by name, ttext,author
        ) pr2
on pr1.name = pr2.name
and pr1.ttext = pr2.ttext
and pr1.author = pr2.author
and pr1.ddate = pr2.ddate

相关问题