zoukankan      html  css  js  c++  java
  • SQL常用命令--代码规范comment

    # 建表

    drop database if exists school;
    create database school default charset utf8;
    use school;
    create table tb_college
    (
    collid int auto_increament comment '编号',
    collname varchar(50) not null comment '姓名',
    collintro varchar(50) default '' comment '介绍',
    primary key (collid)
    );
    create table tb_student
    (
    stuid int not null comment '',
    stuname varchar(20) not null comment '',
    collid int not null comment '',
    ...
    primary key(stuid),
    foreign key(collid) references tb_college(collid),
    unique(stuid)
    );

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

    # 查询

    select distinct seldate from tb_record;
    select stuname as 姓名,datediff(curdate(),stubirth) dev 365 as 年龄 from ... where ...;
    select avg(score) fromn tb_record where stuid = 1001;
    select avg(score) as 平均分 fromn tb_record group by stuid having 平均分 >= 90;
    select stuname from tb_student t1,tb_course t2 where stuid = sid and couid = cid; --多表查询
    select stuname from tb_student inner join tb_record on stuid = sid; --此处on

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

  • 相关阅读:
    PHP运行及语句及逻辑
    数据库基础,表及SQL语句
    php后台修改人员表信息
    php后台增加删除修改跳转页面
    用PHP访问数据库
    php登录注册页面及加载
    php做登录注册页面及加载
    实现基于物理的渲染
    Tile-Based Deferred Rendering
    矩阵基础 2
  • 原文地址:https://www.cnblogs.com/bernard-shen/p/14466609.html
Copyright © 2011-2022 走看看