zoukankan      html  css  js  c++  java
  • mysql学习(九)sql语句

    SQL种类:

    DDL:数据定义语言

    DML:数据操作语言

    DQL:数据查询语言

    DCL:数据控制语言

    DDL:

    1. show databases; //查询数据库
    2. create database if not exists sqldb;//创建一个数据库
    3. use sqldb; //使用一个sqldb
    4. show tables; //显示表
    5. create table if not exists cats(id int not null auto_increment, pid int not null default '0', name varchar(16) not null default '', desn text not null default '',  primay key(id), key name(name, pid)); //创建数据表
    6. create table if not null exists products(id int not null auto_increment, cid int not null default '0', name varchar(16) not null default '', num int not null default '0', price double(10, 2) not null default '0.00', desn text not null default '', primary key(id), key name(name, price));//创建表

    DML:数据操作语言 insert update delete

    1. desc products; //查看表结构
    2. insert into products(cid, name, price, num, desn) values('0', 'dda', '10.20', '2', 'this is a java');// 插入记录
    3. insert into products values(null, '0', 'java', '10', '10.10', 'this is a java!');
    4. update procudts set num = 1 where id = 1;//更新语句
    5. update products set name = 'php', desn = 'this is php' where id = 2; //更新语句
    6. delete from products where id = 1;//删除id = 1的记录

    DQL:数据查询语句

    select [all | distinct]

    [字段名 as 别名]

    from

    表名

    [where  条件语句]

    [group by ....]

    [having....]

    [order by...]

    [limit count]

    1. where 语句 select update delete

    逻辑运算(多个条件)

    &&   ||  !

    and  or  not

    比较运算

    <=>

    >

    <

    =

    != / <>

    >=

    <=

    IS NULL

    NOT NULL

    BETWEEN AND

    NOT BETWEEN AND

    IN

    LIKE 模糊查询  _:一个任意字符 %:0个或者多个字符

    NOT LIKE:

    REGEXP 正则表达式

     

  • 相关阅读:
    React使用iconfont图标下载到本地symbol引用
    【汇编】求100以内的素数asm
    jQuery Ajax.BeginForm方法回调函数高版本3.3.1不兼容问题
    python中的深拷贝与浅拷贝
    闲来无事做个C#小项目——2
    C#使用MD5加密
    数据结构部分总结(c语言版)
    vue 上传视频和图片 并且截取视频第一帧作为播放前默认图片
    vue el-cascader取id和lable的值
    C# 枚举的定义,枚举的用法,获取枚举值
  • 原文地址:https://www.cnblogs.com/zhoulikai/p/3360302.html
Copyright © 2011-2022 走看看