我有两张桌子,上面有一千条记录,供学生每年参加活动:
table1
year | Id | Activity | Name
2001 1 a Mike
2001 1 b Mike
2002 1 c Mike
2003 1 c Mike
table2
Year | Id | Grade
2001 1 7
2002 1 8
2003 1 9
我想以下面的格式获取查询,
我仍然无法理解。请帮忙
year | Id | Activity | Name | Grade |
2001 1 a Mike 7
2001 1 b Mike 7
2002 1 c Mike 8
2003 1 c Mike 9
这是我写的
Select t1.year,t1.Id,t1.Activity,t1.Name,t2.Grade
FROM table1 t1 INNER JOIN table2 t2 ON t2.year=t1.year AND t2.Id=t1.Id
答案 0 :(得分:1)
Select t1.year,t1.Id,t1.Activity,t1.Name,t2.Grade
FROM table1 t1 INNER JOIN table2 t2 ON t2.year=t1.year AND t2.Id=t1.Id
答案 1 :(得分:-1)