mysql_操作数据表中的记录

插入记录

INSERT [INTO] table_name [(col_name,…)] {VALUES|VALUE} ({expr|DEFAULT},…),(…),…

可以插入多列

INSERT [INTO] table_name [(col_name,…)] SELECT …

将查询结果插入到指定数据表

更新记录

UPDATA [LOW_PRIORITY] [IGNORE] table_reference SET col_name1={expr1|DEFAULT} [col_name2={expr2|DEFAULT}] [WHERE where_condition]

    UPDATA users SET age = age + 5;
    UPDATA users SET age = age -id, sex = 0;
    UPDATA users SET age = age + 10, WHERE id%2=0;

删除记录

DELETE FROM tab_name [WHERE where_condition]

查询记录

SELECT select_expr[, select_expr …]

[

FROM table_references

[WHERE where_condition]

[GROUP BY {col_name | position} [ASC | DESC], …]

[HAVING where_condition]

[ORDER BY {col_name | expr | position} [ASC | DESC], …]

[LIMIT {[offset, ]row_count | row_count OFFSET offset}]

]

SELECT username AS name // as 别名

    原文作者:supa同学
    原文地址: https://www.jianshu.com/p/d906b5899deb
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞