比如查询某个表中相同ID中登记时间最大的记录:
select * from bb t where exists (selec * form bb where id=t.id and 登记时间
select a.* from bb a,(select id,max(登记时间) as 登记时间 from bb group by id) b
where a.id=b.id and a.登记时间=b.登记时间
(SQL语句) exists (语句),如果没有exists,还可用where ,join , not ,in 等等,SQL是很丰富的,这个要自己平常多去学习,具体用法也要多用才能掌握其中的奥妙。
PublishDate 是一个字段
(SELECT TOP 1 * FROM articles WHERE SysCategory='2' ORDER BY PublishDate DESC) 是多个字段
一个字段和多个字段无法比较的.
要把
(SELECT TOP 1 * FROM articles WHERE SysCategory='2' ORDER BY PublishDate DESC)
改成
(SELECT TOP 1 PublishDate FROM articles WHERE SysCategory='2' ORDER BY PublishDate DESC)
我也想知道的