我有两张桌子,我加入了它们。
结果表包含重复的id
个。
如何保留这些重复记录的最后一条记录?
此外,table3包含一组id
s,应该从之前获得的结果表中删除。
该命令应该是什么?
start_date = datetime.datetime(2018,1,1)
cmd1 = "(select id, filename from table1 where group = 1) m"
cmd2 = "(select id, type, date from table2 where is_good = 1 and date > '" + start_date.strftime('%Y-%m-%d') +"') n "
cmd = "select m.id, m.filename, n.type, n.date, from " + \
cmd1 + " join " + cmd2 + " on " + "m.id = n.id"