php主要实现B/S

.net IIS java TomCat

LAMP: Linux 系统 A阿帕奇服务器 Mysql数据库 Php语言(KE)

mysql:c常用代码

create table ceshi1
(
uid varchar (50) primary key,
pwd varchar (50),
name varchar (50),
nation varchar (50),
foreign key (nation) references nation(code)
)

写查询语句需要注意:

1,创建表的时候,最后一列后面不要写逗号

2,如果有多条语句一起执行,注意在语句之间加分号分隔

3,写代码时所有的符号都是半角的

关系型数据库:表和表之间是有关系存在的

创建表的几个关键字:

1,主键: primary key

2,非空:not null

3,自增长列:auto_increment

4,外键关系: foreign key (列名) references 表名(列名)

CRUD操作

1,添加数据
insert into info values("","","",) 要求values括号里面的值得个数要和表里面的列数相同

insert into info (code,name) values ("","") 添加指定列的值

2,修改数据

update info set name = "张三" where code="poo1"

3,删除数据

delete from info where code = "poo1"

4,查询数据

1.普通查询,查所有的

select * from info #查所有数据

select code,name from info #查指定列

2.条件查询

select * from info where code = "poo1" #一个条件

select * from info where name = "张三" and nation = "n001"

#两个条件并的关系

select * from info where name = "张三" or nation = "n001"

#两个条件或的关系

3.排序查询

select * from info order by birthday #默认升序排列 asc ;降序排列 desc

select * from car order by brand asc, oil desc #多列排序

4.聚合函数

select count(*) from info #q取个数

select sum(price) from car #查询price列的和

select avg(price) from car #查询price列的平均值

select max(price) from car #查询price列的最大值

select min(price) from car #查询price列的最小值

5.分页查询

select * from car limit (n-1)*5,5 #跳过 (n-1)*5 条数据取 m 条数据

6.分组查询

select brand from car group by brand #简单的分组查询

select brand from car group by brand having count(*)>2

#查询系列里面车的数量大于2的系列

7.去重查询

select distinct brand from car

8.修改列名

select brand as "系列" from car

9.模糊查询

select * from car where name like "奥迪%" #%代表“奥迪”开头

select * from car where name like "%奥迪%" #包含“奥迪”

select * from car where name like "_奥迪%" #“奥迪”前只有一个

10.离散查询

select * from car where code in ("c001","c002","c003")

select * from car where code not in ("c001","c002","c003")

高级查询:

1.连接查询

select * from info,nation #得出的结果,称为笛卡尔积

select * from info,nation where info.nation = nation.code

join on 链接

select * from info join nation #join 链接,笛卡尔积

select * from info join nation on info.nation = nation.code

2.联合查询

select code,name from info
union
select code,name from nation #查询的列相同

3.子查询

1) 无关子查询
select code from nation where name = "汉族"
#去nation表中查汉族的民族代号

select * from info where nation = ()
#在info表中查询民族代号为上一个查询结果的所有信息

select * from info where nation = (select code from nation where name = "汉族" )

子查询 查询的结果被父查询使用,子查询可以单独执行的成为无关子查询

2) 相关子查询

select * from car where oil < (该系列的平均油耗)
#查询油耗小于该系列平均油耗的

select avg(oil) from car where brand = "值"
#查询某系列的平均油耗

select * from car a where oil < (select avg(oil) from car b where b.brand = a.brand)

mySQL笔记2的更多相关文章

  1. MySQL笔记汇总

    [目录] MySQL笔记汇总 一.mysql简介 数据简介 结构化查询语言 二.mysql命令行操作 三.数据库(表)更改 表相关 字段相关 索引相关 表引擎操作 四.数据库类型 数字型 字符串型 日 ...

  2. 涂抹mysql笔记-数据库中的权限体系

    涂抹mysql笔记-数据库中的权限体系<>能不能连接,主机名是否匹配.登陆使用的用户名和密码是否正确.mysql验证用户需要检查3项值:用户名.密码和主机来源(user.password. ...

  3. centos7.2下安装Mysql笔记

    centos7.2下安装Mysql笔记 安装 MySQL 适用于 CentOS 7.0 或以后版本: yum install mariadb mariadb-server 适用于 CentOS 6.8 ...

  4. MySQL笔记(六)游标练习

    23.3.1 Trigger Syntax and Examples 意义不明的几道练习,留着备用. 感觉不好写,而且难以调试..不知道以后会不会有实际的应用场景. 环境:MySQL 笔记(三)由 t ...

  5. mysql 笔记(一)

    mysql 笔记 预留 mysql> use mysql; mysql> grant all privileges  on *.* to root@'%' identified by &q ...

  6. 【MySQL笔记】SQL语言四大类语言

     SQL语言共分为四大类:数据查询语言DQL,数据操纵语言DML,数据定义语言DDL,数据控制语言DCL.   1. 数据查询语言DQL 数据查询语言DQL基本结构是由SELECT子句,FROM子句, ...

  7. Mysql 笔记二

    Mysql 笔记二 Mysql 笔记二 Table of Contents 1. 前言 2. Master Thread 工作方式 2.1. 主循环(loop) 2.2. 后台循(backgroup ...

  8. 深入浅出mysql笔记---1、mysql下载安装

    深入浅出mysql笔记---1.mysql下载安装 一.总结 一句话总结: linux下rpm安装即可 1.linux的wget命令作用? 下载文件的工具:比如wget http://cn.wordp ...

  9. 深入浅出mysql笔记---0、序

    深入浅出mysql笔记---0.序 一.总结 一句话总结: 心得:买书之前建议先找找电子书,纸质书太难带了 1.开源作用? 开源对mysql的发展至关重要 2.mysql在2002年就全面支持了事务, ...

  10. 最全mysql笔记整理

    mysql笔记整理 作者:python技术人 博客:https://www.cnblogs.com/lpdeboke Windows服务 -- 启动MySQL net start mysql -- 创 ...

随机推荐

  1. EF实体框架之CodeFirst七

    前面的6篇博客基本把Code First学习的差不多了,今天这篇学习下code first中的并发控制和事务,基本也快学完了,顶多就差数据迁移. 在数据库中也是有锁和事务的概念,在C#中也是存在,当然 ...

  2. DELL VENUE 11 PRO系统损坏之后的解决办法

    首页说明下我的平板是dell venue 11 pro atom版+win8.1版. 前两天测试玩win10,结果后来几天这货直接开不了机了,每次提示自动修复,但是却说找不到某一文件,然后蓝屏,win ...

  3. [工具类]获取url中参数列表

    写在前面 在项目中经常用到解析url中参数的逻辑,今天先下载就自己封装了一个方法,方便以后使用的时候,信手拈来.当然这里给出的方法是针对常见的url参数类型的,对于重写url,或者路由格式的不考虑. ...

  4. DOM(八)使用DOM控制表单

    1.表单简介 表单<form>是网页中交互最多的形式之一,它通过各种形式接收用户的数据,包括下拉列表框,单选按钮,复选框和文本框,本篇主要介绍表单中常用的属性和方法 javascript中 ...

  5. 常用js正则

    selectedName = selectedName.replace(/,$/, '');//去除尾部字符串 selectedCode = selectedCode.replace(/,$/, '' ...

  6. 【团队项目演示】FZU5BOYS之团队项目链接汇总

    FZU5BOYS      项目冲刺之博客汇总 Alpha版本 Day One Day Two Day Three Day Four Day Five Day Six Day Seven Day Ei ...

  7. javaee添加验证码

    package com.zh.code; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import j ...

  8. 小菜鸟学 MQ(一)

    第一步: 从http://activemq.apache.org/ 下载相关文件. apache-activemq-5.8.0-bin.zip 解压到指定目录下. 第二步: cmd 下切换到   mq ...

  9. hdu3613 扩展KMP

    #include<stdio.h> #include<string.h> #define maxn 501000 char s[maxn],t[maxn]; int next[ ...

  10. Learn sed using these command on Linux(流线式编辑器——sed)

    是对文件中的每一行进行处理,不会对源文件进行修改 sed --version sed '11d' sed_file sed -n '/[Bb]erry/p' sed_file (由于设置了n,所以只打 ...