当前位置: 首页 > news >正文

淘宝客cms网站建设杭州网站建设 巴零

淘宝客cms网站建设,杭州网站建设 巴零,品牌设计的概念,自己开平台怎么弄啊-- 查询所有数据库 show databases; -- 创建数据库,数据库名为mydatabase create database mydatabase; -- 如果没有名为 mydatabase的数据库则创建,有就不创建 create database if not exists mydatabase; -- 如果没有名为 mydatabase的数据库则创建…

-- 查询所有数据库

show databases;

-- 创建数据库,数据库名为mydatabase

 

create database mydatabase;


-- 如果没有名为 mydatabase的数据库则创建,有就不创建

 

create database if not exists mydatabase;

-- 如果没有名为 mydatabase的数据库则创建,有就不创建,数据库字符编码设置为utf8mb4

create database if not exists mydatabase character set utf8mb4;

-- 使用数据库

use mydatabase;

-- 删除名为mydatabase的数据库

drop database mydatabase;

-- 如果有名为 mydatabase的数据库则删除,没有就不删除

drop database if exists mydatabase;

-- 查看mydatabase数据库的表结构

desc mydatabase;

-- 创建表,comment用于字段说明,创建一个表有id,name,gender,age,class字段

create table mytable(id int not null ,name varchar(20) not null comment '姓名',gender varchar(2) not null comment '性别',age int not null comment '年龄',class varchar(20) not null comment'班级'
);

-- 删除名为mytable的表

drop table mytable;

-- 如果存在则删除mytable表,不存在就不删除

drop table if exists mytable;

-- 数据库主要有增删查改等操作

-- 创建一个学生表student,字段有id ,sn, name,qq_meail

create table student (id int ,sn int comment '学号',name varchar (20) comment '姓名' ,qq_email varchar(32) comment 'qq邮箱'
);

-- 增,插入数据

insert into student (id,sn,name,qq_email) values (1,'10000','张三','123456@qq.com');

-- 可以指定列插入
 

insert into student (sn,name,qq_email) values( '1002','李四','234567@qq.com');


 -- 查,查询记录
 -- 查询student表里所有字段
 -- 一般不用这种全列查询,因为全列查询效率低

 select * from student;


 -- 查询student表里的指定列 sn,name,qq_email

 select sn,name,qq_email from student;


 
 -- 查询字段也可以进行表达式运算

 select sn+10,name,qq_email from student;


 -- 再比如,插查询字段为id, name, chninese,english,math三门成绩相加

 select id,name,chinese+english+math from student;


 -- 数据库约束
 
 -- NULL约束,当字段设置为not null,那么这一列就不能为空

 create table student (id int  not null ,name varchar(32) not null,age int not null);


 
 -- unique约束:指定字段的某列是唯一的,不可以重复的
 -- 创建一个学生表,id为主键自增,sn设置为唯一的unique

 drop table if exists student ;create table student(id int not null primary key auto_increment,sn int unique comment '学号',name varchar(32) not null comment '名字');


 -- default约束:规定没有给列赋值时可以给一个默认值
-- 当name不知道时设置默认为'未知'
 

drop table if exists student;create table student (id int not null primary key auto_increment,sn int unique comment '学号',name varchar(32) default  '未知' comment '名字');


 -- 主键约束
 -- id为主键且设为自增

 drop table if exists student;create table student (id int not null primary key auto_increment,sn int  comment '学号',name varchar(32) comment '名字');


 
 -- 外键约束:外键约束用来关联表之间的关系,可以用来关联其他表的主键
 -- 添加外键约束语法  foreign key (字段名) references (主表的列)
 

1.查询与过滤

题目:现在运营想要查看用户信息表中所有的数据,请你取出相应结果

select*from user_profile;

题目:现在运营同学想要用户的设备id对应的性别、年龄和学校的数据,请你取出相应数据

select device_id,gender,age,university from user_profile;

 题目:现在运营需要查看用户来自于哪些学校,请从用户信息表中取出学校的去重数据。

select  distinct university from user_profile;

题目:现在运营只需要查看前2个用户明细设备ID数据,请你从用户信息表 user_profile 中取出相应结果。

-- LIMIT n OFFSET m:从第m+1条开始,取n条数据
select device_id from user_profile limit 2 offset 0;

题目:现在你需要查看前2个用户明细设备ID数据,并将列名改为 'user_infos_example',,请你从用户信息表取出相应结果。

select device_id as user_infos_example from user_profile limit 2 offset 0;

题目:现在运营想要筛选出所有北京大学的学生进行用户调研,请你从用户信息表中取出满足条件的数据,结果返回设备id和学校。

select device_id,university from user_profile where university='北京大学';

题目:现在运营想要针对24岁以上的用户开展分析,请你取出满足条件的设备ID、性别、年龄、学校。

select device_id,gender,age,university from user_profile where age>=24;

题目:现在运营想要针对20岁及以上且23岁及以下的用户开展分析,请你取出满足条件的设备ID、性别、年龄。

select device_id,gender,age from user_profile where age>=20 and age<=23;

题目:现在运营想要查看除复旦大学以外的所有用户明细,请你取出相应数据

select device_id,gender,age,university from user_profile where university!='复旦大学';

题目:现在运营想要对用户的年龄分布开展分析,在分析时想要剔除没有获取到年龄的用户,请你取出所有年龄值不为空的用户的设备ID,性别,年龄,学校的信息。

select device_id,gender,age,university from user_profile where age is not null;

http://www.yayakq.cn/news/293508/

相关文章:

  • 网站建设与运营 教材 崔搜索引擎优化seo专员
  • 微网站是用什么代码制作企业官方网站怎么做
  • 衡水网站优化推广广州站八个字
  • 徐州市制作网站的公司台州网红
  • 商丘做手机做网站什么都可以看的浏览器
  • 做emc的有哪些网站镇江网络科技有限公司
  • 山东网站seo开发系统管理员已阻止这个应用
  • 昆明网站建设推广服务临海网站建设公司
  • 大连网站开发培训班天元建设集团有限公司招聘2022
  • 从电子商务网站f型眼球轨迹分析其网站布局手机制作网站开发
  • 网上做期末试卷的网站网站如何设置微信支付功能
  • 搭建淘宝客网站源码龙华做网站的
  • 小程序开发平台哪个产品好蚌埠网站优化
  • 赣州建设局 网站济南建设大厦
  • 教你如何建设一个模板网站黄冈网站建设优化排名
  • 东莞网站建设设计价格无锡网站制作哪些
  • 深圳需要做网站的公司有哪些网站建设规范管理工作
  • 在线旅游网站平台有哪些wordpress怎样弄栏目
  • 有口碑的番禺网站建设西宁网站建设最好的公司
  • 易烊千玺个人网站入口有区域名和主机怎么做网站
  • 网站络国外活动策划网站
  • 国内网站有哪些遵义网站建设公司有哪些
  • 网站建设工资一月多少网站内容结构
  • 杭州城西做网站的公司开网店卖什么好
  • 网站开发 pptqq怎么做自己的网站
  • 用ps软件做ppt模板下载网站有哪些网站维护哪些
  • 建设高端网站公司的目的一个新网站关键词怎么做SEO优化
  • 门户网站营销常用的网络推广方式有哪些
  • 网站开发维护前景制作手机广告的网站
  • 鞍山58同城官网莆田百度快照优化