mysql 常用函数
一、常用字符串函数
1.CONCAT(str1,str2,...)
mysql> ? concat;
mysql> SELECT CONCAT('My', 'S', 'QL');
+-------------------------+
| CONCAT('My', 'S', 'QL') |
+-------------------------+
| MySQL |
+-------------------------+
2.INSERT(str,pos,len,newstr)
mysql> ? insert function;
mysql> SELECT INSERT('Quadratic', 3, 4, 'What');
+-----------------------------------+
| INSERT('Quadratic', 3, 4, 'What') |
+-----------------------------------+
| QuWhattic |
+-----------------------------------+
3.LOWER(str)
mysql> ? lower
mysql> SELECT LOWER('QUADRATICALLY');
+------------------------+
| LOWER('QUADRATICALLY') |
+------------------------+
| quadratically |
+------------------------+
4.UPPER(str)
mysql> ? upper
mysql> SELECT UPPER('Hej');
+--------------+
| UPPER('Hej') |
+--------------+
| HEJ |
+--------------+
5.LEFT(str,len)
mysql> ? left
mysql> SELECT LEFT('foobarbar', 5);
+----------------------+
| LEFT('foobarbar', 5) |
+----------------------+
| fooba |
+----------------------+
6.RIGHT(str,len)
mysql> ? right
mysql> SELECT RIGHT('foobarbar', 4);
+-----------------------+
| RIGHT('foobarbar', 4) |
+-----------------------+
| rbar &
相关文档:
语法:
/usr/local/mysql/bin/mysqladmin -u username -p newpassword
系统会提示您输入旧密码:
按Enter后,系统将旧的密码改成newpassword,
注意newpassword不是命令,是一个字串,就是新密码的字串,你可以更改成其它的.
-u后面跟着是用户名,就是你所要更改的用户名. ......
查询及删除重复记录的方法
(一)
1、查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断
select * from people
where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)
2、删除表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断,只留有rowid ......
***function(/*常用函数*/)***
----统计函数----
AVG --求平均值
COUNT --统计数目
MAX --求最大值
MIN --求最小值
SUM --求和
--AVG
use pangu
select avg(e_wage) as dept_avgWage
from employee
group by dept_id
--M ......