摘要: 常用的内置函数,常用select\字符串函数contat('' , '', .....) //连接字符串 select concat(name, ' age is ', age) from persons;insert(a, 2, 3, insert) //将字符a的第2个位置开始,3个字符替换为insertmysql> select name, insert(name, 2, 3, 'hello') from persons;+------------+-----------------------------+| nam 阅读全文
posted @ 2013-10-10 23:34 激扬飞雪 阅读(289) 评论(0) 推荐(0) 编辑
摘要: select * from products where id in(select id from cats where name like '%java%');//查找类型中名字中包含java的的商品信息order by 字段名字 desc /ascselect * from products order by price desc;//按照降序排列limitselect * from products order by price limit 1;//取出价格便宜的商品select * from products where id select * from product 阅读全文
posted @ 2013-10-10 17:30 激扬飞雪 阅读(934) 评论(0) 推荐(0) 编辑
摘要: 多表查询时,要给表名起别名,给字段名其别名(当两个表含有重复字段时)select p.name, c.name, pid from products p, cats c;//得到的结果为笛卡尔乘积select p.name as pname, p.price, p.desn, p.num from products p, cats c where c.id = p.cid ;//查询所有商品属于哪个分类select p.name as pname, p.price, p.desn, p.num from products p, cats c where c.id = p.cid and c.n 阅读全文
posted @ 2013-10-10 15:47 激扬飞雪 阅读(394) 评论(0) 推荐(0) 编辑
摘要: http://hi.baidu.com/kevin276/item/29bc1c96a208fabc82d29542sudo dpkg -i google-chrome-stable_current_amd64.debsudo apt-get -f install 阅读全文
posted @ 2013-10-10 14:55 激扬飞雪 阅读(184) 评论(0) 推荐(0) 编辑
摘要: SQL种类:DDL:数据定义语言DML:数据操作语言DQL:数据查询语言DCL:数据控制语言DDL:show databases; //查询数据库create database if not exists sqldb;//创建一个数据库use sqldb; //使用一个sqldbshow tables; //显示表create table if not exists cats(id int not null auto_increment, pid int not null default '0', name varchar(16) not null default '& 阅读全文
posted @ 2013-10-09 22:52 激扬飞雪 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 数据存储引擎: MyISAM:强化快速读取操作、 也有缺点、一些功能不支持 InnoDB:支持一些MyIASM一些不支持的功能 缺点:占用空间大 对比 MyISAM InnoDB 事务处理 不支持 支持 数据锁定 不支持 支持 外键 不支持 支持 表占用空间 相对小 2倍数 全文索引 支持 不支持 创建数据表制定存储引擎 create table if not exists persons(id int not null auto_increment primary k... 阅读全文
posted @ 2013-10-08 22:35 激扬飞雪 阅读(186) 评论(0) 推荐(0) 编辑
摘要: mysql 远程链接问题 阅读全文
posted @ 2013-10-08 16:46 激扬飞雪 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 常规索引: 在常用查询的字段上使用常规索引 创建表时一块创建索引 create table if not exists carshop(id int not null auto_increment, uid int not null, gid int not null, primay key(id), index cuid(uid), key cgid(gid)); create table if not exists carshop(id int not null auto_increment, uid int not null, gid int not null, prima... 阅读全文
posted @ 2013-09-30 11:59 激扬飞雪 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 主键索引: 确定唯一的一条记录,只能有一个主键(primary key) 主键不能为空 1、create table if not exists t1(id int not null auto_increment primary key, name varchar(10) not null default ''); 2、create table if not exists t1(id int not null auto_increment, name varchar(10) not null default '', primary key(id));唯一索引:( 阅读全文
posted @ 2013-09-29 15:26 激扬飞雪 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 字段属性:unsigned: 无符号类型,只能修饰数值类型;create table if not exists t1(id int unsigned);zerofill:前端填0 //只能修饰数值类型create table if not exists t1(id int(4) zerofill, price float(10,3) zerofill, name varchar(10));auto_increment: 自动增长create table if not exists t1(id int auto_increment primary key, name varchar(10)); 阅读全文
posted @ 2013-09-29 13:50 激扬飞雪 阅读(175) 评论(0) 推荐(0) 编辑