「MySQL」三角関数の使い方

2021年12月30日

書式
SIN(X)
COS(X)
TAN(X)
COT(X)

引数に指定した値の正弦(サイン)、余弦(コサイン)、正接(タンジェント)、余接(コタンジェント)を返します。

使用例
SQL構文

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
select sin(pi()/3) resA, cos(pi()/3) resB, tan(pi()/3) resC,cot(pi()/3) resD;
select sin(pi()/3) resA, cos(pi()/3) resB, tan(pi()/3) resC,cot(pi()/3) resD;
select sin(pi()/3) resA, cos(pi()/3) resB, tan(pi()/3) resC,cot(pi()/3) resD;

実行結果

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
resA         resB         resC         resD
0.8660254037844386 0.5000000000000001 1.7320508075688767 0.577350269189626
resA         resB         resC         resD 0.8660254037844386 0.5000000000000001 1.7320508075688767 0.577350269189626
resA	        resB	        resC	        resD
0.8660254037844386	0.5000000000000001	1.7320508075688767	0.577350269189626

 

MySQL

Posted by arkgame