select distinct title from A 这句就是去重复的,然后把你的排序的加上就行了。
to javagxc -------------------- select distinct title from A 这句就是去重复的,然后把你的排序的加上就行了。 --------------------这样没法按操作时间排序啊? 表B dotime(操作时间) 就是对表A 的 历史操作记录
select distinct title from A 这样我试过, 再加上 排序时间, 语法错误啊
某一userid 的title的列表,并且同一个标题允许一次出现,按dotime时间 倒序排列 select b.dotime,a.title from a,b where a.aid=b.aid and a.userid='1' order by b.dotime楼主是否需要查询出b.dotime这个字段》还是只是用来排序?如果只是用来排序jiu从查询结果去掉,然后加上diatinct关键字即可。 如果确实需要的话,那这个语句就可能要进行特殊处理了。select b.dotime,a.title from a,b where a.aid=b.aid and a.userid='1' and b.dotime= (select max(dotime) from a,b where a.aid=b.aid where a.aid=b.aid group by a.userid,a.title) order by b.dotime乱写的。
select * from (select a.title,max(b.dotime) dtime from a,b where a.aid=b.aid and a.userid = 某一userid group by a.title) order by dtime
select title from (select a.title,max(b.dotime) dtime from a,b where a.aid=b.aid and a.userid = 某一userid group by a.title) order by dtime
这句就是去重复的,然后把你的排序的加上就行了。
--------------------
select distinct title from A
这句就是去重复的,然后把你的排序的加上就行了。
--------------------这样没法按操作时间排序啊? 表B dotime(操作时间) 就是对表A 的 历史操作记录
这样我试过, 再加上 排序时间, 语法错误啊
select b.dotime,a.title from a,b where a.aid=b.aid and a.userid='1'
order by b.dotime楼主是否需要查询出b.dotime这个字段》还是只是用来排序?如果只是用来排序jiu从查询结果去掉,然后加上diatinct关键字即可。
如果确实需要的话,那这个语句就可能要进行特殊处理了。select b.dotime,a.title from a,b where a.aid=b.aid and a.userid='1' and b.dotime=
(select max(dotime) from a,b where a.aid=b.aid where a.aid=b.aid group by a.userid,a.title)
order by b.dotime乱写的。