多表查询,既想去掉重复记录,又想按任意字段排序。
tbl_1:
book_id name insert_date
1 a 20070101
2 b 20070102
3 c 20070103
tbl_2:
author_id book_id author
1 1 tom
2 1 lily
3 2 green
4 2 zhangsan
5 3 lisi
比如有如上两个表,实际中有好多表联合查询
能不能用一条sql语句技能去除book_id重复的记录又能按inset_date排序呢?
试过group by ,但在postgres中好像不行,’distinct book_id‘吧,又不能按日期排序,有哪位postgres熟练的高手指点一下啊,困惑中。
tbl_1:
book_id name insert_date
1 a 20070101
2 b 20070102
3 c 20070103
tbl_2:
author_id book_id author
1 1 tom
2 1 lily
3 2 green
4 2 zhangsan
5 3 lisi
比如有如上两个表,实际中有好多表联合查询
能不能用一条sql语句技能去除book_id重复的记录又能按inset_date排序呢?
试过group by ,但在postgres中好像不行,’distinct book_id‘吧,又不能按日期排序,有哪位postgres熟练的高手指点一下啊,困惑中。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货