题目 :https://leetcode.cn/problems/triangle-judgement/
数据
Create table If Not Exists Triangle (x int, y int, z int)
insert into Triangle (x, y, z) values ('13', '15', '30')
insert into Triangle (x, y, z) values ('10', '20', '15')
需求
查询,每三个线段是否可以形成一个三角形
查询结果 :
| x | y | z | triangle |
| 13 | 15 | 30 | No |
| 10 | 20 | 15 | Yes |
解决
三角判断 :
- 所有边的 俩边之和 > 第三边
select x, y, z,
if((x + y > z)&(x + z > y)&(y + z > x), 'Yes', 'No') as triangle
from Triangle