以前的写法:

SELECT stu.*, sc.C,sc.score FROM student stu,sc sc1,sc sc2,sc sc

WHERE stu.S = sc.s AND stu.S = sc1.S AND stu.S = sc2.S
AND sc1.C = '01' AND sc2.C = '02' AND sc1.score > sc2.score


现在的写法:

select stu.*, sc.C,sc.score from student  stu --8  2^3
left  join sc sc on stu.S = sc.s  --19  2^4+3
left  join sc sc1 on stu.S = sc1.s --AND sc1.C = '01'  -49  2^5 +17
left  join sc sc2 on stu.S = sc2.s -- AND sc2.C = '02'  --133
where sc1.C = '01' AND sc2.C = '02' AND sc1.score > sc2.score

select * from student
select * from sc
1 2 3 4 4*3 12   4*9 36  4*27    108
5 6 7   3*2 6     3*4  12  3*8   24

8       1*1        1*1  1  1*1   1



sql 左连接


sql 左连接sql 左连接

相关文章:

  • 2021-10-03
  • 2022-01-20
  • 2022-12-23
  • 2021-04-30
  • 2022-01-15
  • 2022-12-23
  • 2021-12-15
  • 2021-11-24
猜你喜欢
  • 2022-12-23
  • 2021-12-30
  • 2022-02-02
  • 2021-12-30
  • 2022-02-04
相关资源
相似解决方案