zoukankan      html  css  js  c++  java
  • 【MYSQL】delete from

    • delete from 单表语法
    DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name  
    [WHERE where_definition]  
    [ORDER BY ...]  
    [LIMIT row_count] 
    • delete from 多表语法
    DELETE [LOW_PRIORITY] [QUICK] [IGNORE]  
    tbl_name[.*] [, tbl_name[.*] ...]  
    FROM table_references  
    [WHERE where_definition] 
    
    或
    
    DELETE [LOW_PRIORITY] [QUICK] [IGNORE]  
    FROM tbl_name[.*] [, tbl_name[.*] ...]  
    USING table_references  
    [WHERE where_definition] 

    delete from  简单示例

    mysql> select * from ns;
    +-----+-------+------------+
    | uid | uname | udate2     |
    +-----+-------+------------+
    |   2 | alex  | 1989-01-10 |
    |   7 | uuuu  | 0000-00-00 |
    |   8 | kkkk  | 0000-00-00 |
    |   9 | leb   | 0000-00-00 |
    |  10 | uuuu  | 2000-11-22 |
    |  11 | uuuu  | 1876-11-22 |
    |  12 | uuuu  | 1876-11-22 |
    |  13 | uuuu  | 1223-12-12 |
    +-----+-------+------------+
    8 rows in set (0.00 sec)
    
    mysql> delete from ns where uid=2;
    Query OK, 1 row affected (0.00 sec)
    
    mysql> select * from ns;
    +-----+-------+------------+
    | uid | uname | udate2     |
    +-----+-------+------------+
    |   7 | uuuu  | 0000-00-00 |
    |   8 | kkkk  | 0000-00-00 |
    |   9 | leb   | 0000-00-00 |
    |  10 | uuuu  | 2000-11-22 |
    |  11 | uuuu  | 1876-11-22 |
    |  12 | uuuu  | 1876-11-22 |
    |  13 | uuuu  | 1223-12-12 |
    +-----+-------+------------+
    7 rows in set (0.00 sec)
    
    mysql> delete from ns where uname='leb';
    Query OK, 1 row affected (0.00 sec)
    
    mysql> select * from ns;
    +-----+-------+------------+
    | uid | uname | udate2     |
    +-----+-------+------------+
    |   7 | uuuu  | 0000-00-00 |
    |   8 | kkkk  | 0000-00-00 |
    |  10 | uuuu  | 2000-11-22 |
    |  11 | uuuu  | 1876-11-22 |
    |  12 | uuuu  | 1876-11-22 |
    |  13 | uuuu  | 1223-12-12 |
    +-----+-------+------------+
    6 rows in set (0.00 sec)
    
    mysql> delete from ns where uid in (7,8,9);
    Query OK, 2 rows affected (0.01 sec)
    
    mysql> select * from ns;
    +-----+-------+------------+
    | uid | uname | udate2     |
    +-----+-------+------------+
    |  10 | uuuu  | 2000-11-22 |
    |  11 | uuuu  | 1876-11-22 |
    |  12 | uuuu  | 1876-11-22 |
    |  13 | uuuu  | 1223-12-12 |
    +-----+-------+------------+
    4 rows in set (0.00 sec)
    
    mysql> delete from ns;
    Query OK, 4 rows affected (0.01 sec)
    
    mysql> select * from ns;
    Empty set (0.00 sec)
    •  delete from  与 select 子查询
  • 相关阅读:
    2-SAT 问题及图论解法
    割点、强连通分量
    欧拉路、欧拉回路
    DFS 树
    【题解】[AGC 034 F] RNG and XOR【异或卷积 FWT】
    【题解】[UOJ 62] UR #5 怎样跑得更快【莫比乌斯反演】
    【题解】LOJ #2085 / 洛谷 P1587「NOI2016」循环之美【莫比乌斯反演】
    【题解】LOJ #6052 「雅礼集训 2017 Day11」DIV【莫比乌斯反演】
    【题解】[HDU 5382] GCD?LCM【莫比乌斯反演 差分 线性筛】
    【题解】[51Nod 1847] 奇怪的数学题【min_25筛 杜教筛 莫比乌斯反演】
  • 原文地址:https://www.cnblogs.com/AlexBai326/p/6050000.html
Copyright © 2011-2022 走看看