MySQL - 操作表数据

-- 查询
    -- 单表查询
        -- 查询全部: select * from 表名
        -- 别名: select 字段1 别名, 字段2, ... from 表名
        -- 连接符: select concat(字符1, 字符2) from dual
        -- 去重: select distinct 字段 from 表名
        -- 排序: select * from 表名 order by 字段名
        -- where子句: select * from 表名 where 1=1 
        -- 函数(max, min, avg, sum, count): select max(字段) from 表名
        -- 分组: select * from 表名 group by 字段
        -- having: 分组后筛选
    -- 多表查询
        -- select * from 表1 left join 表2 on 表1.字段 = 表2.字段
    -- 子查询
        -- select * from (select * from 表名)
    
-- 添加
    -- 全部字段插入: insert into 表名 values (值1, 值2, ...);
    -- 部分字段插入: insert into 表名 (字段1, 字段2, ...) values (值1, 值2, ...);

-- 删除
    -- delete from 表名 where 字段 = 值

-- 修改
    -- update 表名 set 字段名 = 值 where 字段 = 值

猜你喜欢

转载自www.cnblogs.com/mpci/p/12293586.html