MySQL常见字符串函数学习
1.reverse(str)函数: 返回颠倒字符顺序的字符串str, 该函数对多字节可靠的.
mysql> select * from user;
+----+------------------+
| id | name |
+----+------------------+
| 1 | test |
| 2 | test2 |
| 3 | abc cde aa bb_cc |
| 4 | abc |
+----+------------------+
4 rows in set (0.00 sec)
mysql> select id,reverse(name) name from user;
+----+------------------+
| id | name |
+----+------------------+
| 1 | tset |
| 2 | 2tset |
| 3 | cc_bb aa edc cba |
| 4 | cba |
+----+------------------+
4 rows in set (0.01 sec)
2.substring(str,start,length)函数:返回str字符串中从开始位置start开始长度为length的字符串。
mysql> select id,substring(name,1,2) name from user;
+----+------+
| id | name |
+----+------+
| 1 | te |
| 2 | te |
| 3 | ab |
| 4 | ab |
+----+------+
4 rows in set (0.00 sec)
注意,第一个字符的位置为1,而不是0.如果用substring(name,0,2),会返回null.
mysql> select id,substring(name,0,2) name from user;
+----+------+
| id | name |
+----+------+
| 1 | NULL |
| 2 | NULL |
| 3 | NULL |
| 4 | NULL |
+----+------+
4 rows in set (0.00 sec)
3.substring_index(str,delim,n)函数:返回字符串str中第n次出现delim字符之前的所有字符,如果n为负数,则表示从反方向开始计数。
mysql> select * from user;
+----+----------------------------
相关文档:
解决mysql“Access denied for user
我的系统是ubuntu6.06,最近新装好的mysql在进入mysql工具时,总是有错误提示:
# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
使用网上介绍的方法修改root用户的密码:
# mysqladmin -uroot -p p ......
1、新建表test create table test1( field1 int not null ) ENGINE=MyISAM DEFAULT CHARSET=gbk; insert into test1(field1) values(1); 2、删除已存在的存储过程 -- 删除储存过程 delimiter // -- 定义结束符号 drop procedure p_test; 3、mysql存储过程定
1、新建表test
create table test1(
field1 int not null
)
......
下载 ADO.NET Driver for MySQLMySql.Data.dll
安装后,在安装目录下面找到Assemblies
文件夹,找到 MySql.Data.dll
(此文件是.Net访问MySQL数据库的一个驱动,完全ADO.NET数据访问模式,由MySQL官方提供,有多个版本可选择。)
学习的一个链接:http://www.cnblogs.com/wcfgroup/articles/1242256.html
创建一个 ......
1.关键字
auto_increment
2.自增用法
例:
CREATE TABLE animals ( id mediumint not null auto_increment,
name char(30) not null,
primary key (id));
3.关于自增
Q:怎么获得当前的自增的最大值?
A:select @@identity
Q:怎么获得table的当前自增最大值?
A:select max(i ......
PERCONA PERFORMANCE CONFERENCE 2009上,来自雅虎的几位工程师带来了一篇”Efficient Pagination Using MySQL“的报告,有很多亮点,本文是在原文基础上的进一步延伸。
首先看一下分页的基本原理:
mysql> explain SELECT * from message ORDER BY id DESC LIMIT 10000, 20\G
***************** 1. row ** ......