1.floor(x)返回小于x的整数,向下取整,用法,商品的价格是浮点型的,需要向下取整
eg:select id,title,floor(price) from shopgoods
2.rand()返回0-1之间的随机数
select rand()
select rand()*5
3.left(str,x)返回字符串中最左边的x个字符串,下面的SQL语句只显示商品价格的左起第一位
select id,title,left(price,1) from shopgoods
4.right(str,x)与之相反
5.now()返回当前的时间,标准的时间格式非时间戳
6.date_format(时间,'%Y-%m-%-d'),格式化时间
eg: select date_format(now(),'%Y-%m-%d')
7.md5()函数进行md5加密,sha1()函数进行sha1加密
8.version()返回数据库的版本号码
9.length()返回字符串的长度
10.trim()去除字符串首尾空格,类似asp
11.ltrim()去除字符串左边的空格,类似asp
12.rtrim()去除字符串右边的空格,类似asp
13.user()返回当前登陆的用户