We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

select case when a+b<=c and b+c<=a and a+c<=b then 'not a triangle'
when a=b and b=c then 'equilateral'
when a=b or b=c or c=a then 'isosceles'
else 'scalene'
end
from triangles

i wrote this code but then why is it showing error for mysql

SELECT CASE WHEN A + B <= C OR A + C <= B OR B + C <= A THEN 'Not A Triangle'
WHEN A=B AND B=C THEN 'Equilateral'
WHEN A=B OR A=C OR B=C THEN 'Isosceles'
ELSE 'Scalene'
END
FROM TRIANGLES;

## Type of Triangle

You are viewing a single comment's thread. Return to all comments →

select case when a+b<=c and b+c<=a and a+c<=b then 'not a triangle' when a=b and b=c then 'equilateral' when a=b or b=c or c=a then 'isosceles' else 'scalene' end from triangles

i wrote this code but then why is it showing error for mysql

1) Compare casing of letters in printed strings with those of expected output 2) The 'Not A Triangle' conditions appear to be incorrect

did you get the answer for this ?

SELECT CASE WHEN A + B <= C OR A + C <= B OR B + C <= A THEN 'Not A Triangle' WHEN A=B AND B=C THEN 'Equilateral' WHEN A=B OR A=C OR B=C THEN 'Isosceles' ELSE 'Scalene' END FROM TRIANGLES;

THIS WILL WORK NOW IN MYSQL!!!!

It does because the loop will iterate without checking condition