收藏文章 楼主

数据库基础

版块:mysql 数据库通用基础大全   类型:精华   作者:小绿叶技术博客   查看:4997   回复:0   获赞:4   时间:2018-12-03 19:45:06

修改mysql密码:update user set authentication_string=password('root') where user='root' ;

-----------------------------------------------------------------------------------------------------

cd C:\xampp\mysql\bin
mysql -uroot -p
create database eisc;
#创建数据库
use eisc;
#进入数据库
create table eisc(id int,xingming varchar(10),b1 int,b2 int,primary key(id));
#新建键,最后一个设置id为主键
insert into eisc(id,xingming,b1,b2) values(1000,'zhangshan',2001,3001);
#加入表数据,重复输入为加入多个数据
select * from eisc;
#查询表中所有数据

select banzhurenhao from eisc where banjihao in(1701002);
#找班主任号,从eisc表中找班级号是1701002的班主任号

select xingmin from eisc where banjihao in (1701001,1701002);
#查找姓名,从eisc表中找班级号是(1701001,1701002)的所有姓名

select max(b2) as max_b2 from eisc;
#选中一个列b2的最大值,并在新列表中打印,在eisc表格中选取;
#参数:max:最大; min:最小; count avg

======================================================================
#数据库联接查询(链接2个表)

------------------------
select shuhao,chengji,banhao,name 

#联接后需要显示这些表列(在一个表列里添加要显示的表列)

from lianjie,xueshengbiao

#联接这两个表,从这两个表中选取要显示的表列(课程表与连接表)

where xueshengbiao.xuehao=lianjie.xuehao

#执行要求显示,按照两个列表中共有表列且相等的值为链接条件

========================================================================

#链接三个表

-------------

select shuhao,chengji,banhao,name,kecheng 

from lianjie,kecheng,xueshengbiao 

where xueshengbiao.xuehao=lianjie.xuehao 

and kecheng.shuhao=lianjie.shuhao

下载>>>>>MySQL建表导入

===========================================================================


提供企业建站服务,免费网防系统,提交信息登录 http://yundun.ddoss.cn 邮箱: proposal@ddoss.cn 
回复列表
默认   热门   正序   倒序

回复:数据库基础

头像

用户名:

粉丝数:

签名:

资料 关注 好友 消息