mysql>
select
SQRT(16)
+----------+
|
SQRT(16)
|
+----------+
|
4.000000
|
+----------+
1
row
in
set
(0.00
sec)
所看到的浮点值,因为内部MySQL将处理浮点数据类型的平方根。
可以使用SQRT函数,计算出记录的平方根。了解SQRT函数更详细用法,考虑EMPLOYEE_TBL的表具有以下记录:
mysql>
SELECT
*
FROM
employee_tbl
+------+------+------------+--------------------+
|
id
|
name
|
work_date
|
daily_typing_pages
|
+------+------+------------+--------------------+
|
1
|
John
|
2007-01-24
|
250
|
|
2
|
Ram
|
2007-05-27
|
220
|
|
3
|
Jack
|
2007-05-06
|
170
|
|
3
|
Jack
|
2007-04-06
|
100
|
|
4
|
Jill
|
2007-04-06
|
220
|
|
5
|
Zara
|
2007-06-06
|
300
|
|
5
|
Zara
|
2007-02-06
|
350
|
+------+------+------------+--------------------+
7
rows
in
set
(0.00
sec)
假设根据上面的表格,要计算所有的dialy_typing_pages的平方根,然后可以通过使用下面的命令:
mysql>
SELECT
name,
SQRT(daily_typing_pages)
->
FROM
employee_tbl
+------+--------------------------+
|
name
|
SQRT(daily_typing_pages)
|
+------+--------------------------+
|
John
|
15.811388
|
|
Ram
|
14.832397
|
|
Jack
|
13.038405
|
|
Jack
|
10.000000
|
|
Jill
|
14.832397
|
|
Zara
|
17.320508
|
|
Zara
|
18.708287
|
+------+--------------------------+
7
rows
in
set
(0.00
sec)
select curDate()#获取当前日期select curTime()#获取当前时间select now()#获取当前日期+时间列举1个天数加减的例子,其他的看英文意思就可以理解了
select date_add(now(), interval 1 day) #当前日期天数+1
select date_add(now(), interval -1 day) #当前日期天数-1
select date_add(now(), interval 1 hour)
select date_add(now(), interval 1 minute)
select date_add(now(), interval 1 second)
select date_add(now(), interval 1 microsecond)
select date_add(now(), interval 1 week)
select date_add(now(), interval 1 month)
select date_add(now(), interval 1 quarter)
select date_add(now(), interval 1 year)
mysql两点间距,你也自己弄成函数\x0d\x0a\x0d\x0a公式如下,单位米:\x0d\x0a第一点经纬度:lng1 lat1\x0d\x0a第二点经纬度:lng2 lat2\x0d\x0around(6378.138*2*asin(sqrt(pow(sin(\x0d\x0a(lat1*pi()/180-lat2*pi()/180)/2),2)+cos(lat1*pi()/180)*cos(lat2*pi()/180)*\x0d\x0apow(sin( (lng1*pi()/180-lng2*pi()/180)/2),2)))*1000)\x0d\x0a\x0d\x0a例如:\x0d\x0aSELECT store_id,lng,lat,\x0d\x0aROUND(6378.138*2*ASIN(SQRT(POW(SIN((22.299439*PI()/180-lat*PI()/180)/2),2)+COS(22.299439*PI()/180)*COS(lat*PI()/180)*POW(SIN((114.173881*PI()/180-lng*PI()/180)/2),2)))*1000)\x0d\x0aAS\x0d\x0a juli\x0d\x0aFROM store_info\x0d\x0aORDER BY juli DESC\x0d\x0aLIMIT 316欢迎分享,转载请注明来源:内存溢出
评论列表(0条)