winfwu

导航

随笔分类 -  MySQL部分

MySQL卸载后重新安装服务启动不了
摘要:解决方法: 1: 先卸载mysql, 手动将其安装目录里没有删除干净的文件全部删除. 2: 将C:\ProgramData\MySQL 里有关mqsql的文件全部删除. 3: 重新安装 mysql 程序. mysql服务就可以正常启动了 阅读全文

posted @ 2013-05-21 17:35 winfwu 阅读(493) 评论(0) 推荐(0)

MYSQL函数应用----替换函数replace()用法
摘要:『1』实验表结构 cus_a,cus_b表结构; 『2』实验目的实现cus_a表和cus_b表中如果id相等替换name值; UPDATE cus_a a,cus_b b SET b.name=REPLACE(b.name,b.name,a.name) WHERE a.id=b.id;『3』结果如下 阅读全文

posted @ 2013-04-06 11:47 winfwu 阅读(235) 评论(0) 推荐(0)

MYSQL基础----插入,更新,删除数据
摘要:『1』插入数据 -----不指定具体的字段插入数据 insert into 表名 values(值1,值2。。。。); -----指定具体的字段插入数据 insert into 表名(属性1,属性2) values(值1,值2); -----一次性插入多条数据 insert into 表名 values(值1,值2),(值1_1,值2_1),(值1_3,值2_3); -----将查询结果插入表中 insert into 表名1(属性名1) select 属性名2 from 表名2 where 条件表达式;『2』更新数据 update 表名 set 属性名1... 阅读全文

posted @ 2013-04-03 14:47 winfwu 阅读(147) 评论(0) 推荐(0)

MYSQL基础----使用正则表达式查询
摘要:正则表达式的模式字符含义^匹配字符串开始的部分$匹配字符串结束的部分.代表字符串中的任何一个字符,包括回车和换行[字符集合]匹配“字符集合”中的任何一个字符[^字符集合]匹配除“字符集合”外的任何一个字符S1|S2|S3匹配S1,S2,S3中的任意一个字符*代表多个该符号之前的字符,包括0和1个+代表多个该符号之前的字符,包括1个字符串{N}字符串出现N次字符串{M,N}字符串出现至少M次,最多N次 阅读全文

posted @ 2013-04-03 14:33 winfwu 阅读(196) 评论(0) 推荐(0)

MYSQL基础----合并查询结果(UNION)
摘要:『1』UNION 合并并去重 employee表 department表 SELECT * FROM employee UNION SELECT * FROM department; 『2』UNION ALL合并不去重 SELECT * FROM employee UNION ALL SELECT * FROM department; 阅读全文

posted @ 2013-04-03 14:21 winfwu 阅读(2426) 评论(0) 推荐(0)

MYSQL基础----子查询(子查询与IN / 比较运算符 / exists / any /all 连用)
摘要:『1』带IN的子查询 employee表 department表 SELECT num,d_id,name,age,sex,homeaddr FROM employee Where d_id in (select d_id from department); 『2』带比较运算符的子查询 scholarship表 computer_stu表 SELECT id,name,score FROM computer_stu WHERE score>=(select score from scholarship whe... 阅读全文

posted @ 2013-04-03 14:04 winfwu 阅读(803) 评论(0) 推荐(0)

MYSQL基础----链接查询(内连接查询,外连接查询)
摘要:『1』内连接查询 employee表 department表 select num,e.d_id,name,age,sex,homeaddr,d.d_name,d.function,d.address from employee e,department d where e.d_id=d.d_id; 『2』外连接查询 @左连接(Left Join)查询 数据表与上面同步 SELECT num,e.d_id,name,age,sex,homeaddr,d.d_name,d.function,d.address FR... 阅读全文

posted @ 2013-04-02 00:30 winfwu 阅读(335) 评论(0) 推荐(0)

MYSQL基础----集合函数(count,sun,avg,max,min)
摘要:『1』count()函数 略。。。『2』sum()函数 数据表如下: select * from grade; select num,sum(score) from grade where num=1001 group by num; 『3』AVG()函数 select sourse,avg(score) from grade group by sourse;(求各科平均成绩) (4)MAX()函数 select sourse,max(score)from grade group by sourse;(求各科最高分) (5)MIN()函数 select sourse,m... 阅读全文

posted @ 2013-04-02 00:27 winfwu 阅读(569) 评论(0) 推荐(0)

MYSQL基础----ORDER BY关键字 / GROUP BY关键字/ GROUP_CONCAT()函数 / COUNT()函数 / HAVING 关键字 / WITH ROLLUP关键字 / LIMIT关键字
摘要:『1』对查询结果进行排序(默认是按照Asc排序方式排序) select * from employee order by age; 『2』对查询结果进行Eesc排序 select * from employee order by age desc; 『3』多次排序 select * from employee order by d_id asc,age asc; 『4』order by和group_concat函数连用 select sex,group_concat(name) from employee group by sex; 『5』GROUP BY 关键字与COUNT(... 阅读全文

posted @ 2013-04-01 23:07 winfwu 阅读(490) 评论(0) 推荐(0)

MYSQL基础----IS NULL / AND多条件查询 / OR多条件查询 / DISTINCT关键字
摘要:『1』IS NULL查询空值 select * from work; select * from work where sex is null; 『2』多AND条件查询; 表结构如上work; select * from work where name='w3' and id=3 and sex='男' and info='info1'; 『3』多OR条件查询 表结构如上work; select * from work where name='w3' or id=2 or sex='女'; 『4』DISTINCT关 阅读全文

posted @ 2013-04-01 22:28 winfwu 阅读(547) 评论(0) 推荐(0)

MYSQL基础----IN / BETWEEN AND / LIKE关键字用法
摘要:『1』带IN关键字查询 用select * from employee;查询到表结构如下 使用select * from employee where d_id in(1001,1004);SQL语句查询结果如下 使用select * from employee where d_id not in(1001.1004);SQL语句查询结果如下 『2』BETWEEN AND关键字查询 使用employee表做为数据库表。 用select * from employee where d_id between 1003 and 1004; 用select * from e... 阅读全文

posted @ 2013-04-01 21:54 winfwu 阅读(579) 评论(0) 推荐(0)