mysql数据实施_mysql 数据的操作

数据的操作

指定指端写

insert into t1(username,hobby) values ('杨得港','上课,写作业,考试');

insert   into   t2(id,username)   select   id,username  from  t1;

delete   from   表 ;   直接删除表里面的所有信息

delete    from   表   条件;    删除表里面的某一行。   注意下次插入数据的时候,id还是接着写。

会清空表是不会清空自增字段的offset(偏移量)值

truncate   table   表;

会清空表和自增字段的偏移量

删除某一条数据必须带条件

delete   from  表   where   条件;

update   表   set    字段=值   where  条件;    修改一项

update   表    set    字段=值,字段=值     where   条件;     修改多条数据

select   id,emp_name    from   employee;

select  语句

select     *    from   表;

select    字段,....     from     表;

select     字段   as   新名字      from   表;

select     字段   新名字,   from    表;

可以更改显示的名称    select   id   as  i,emp_name  as    name   from    employee;

select    id  i,emp_name   name    from   employee;

查询后去掉重复的值

select    distinct   post   from   表名;

select    distinct    age,gender    from    表名;      只有年龄和性别都一样才会去掉。

四则预算:

select    emp_name,salary*12  from   表名;

select emp_name,salary*12 price from employee;

concat函数:   做拼接用

select  concat(emp_name,':',salary')    from   表名;

concat_ws(':',字段,字段)    from   表名;     表示用:分割字符串

CASE语句   就相当于条件语句  if  函数       case   when   语句   相当于if条件语句

select (

case

when emp_name='jingliyang' then

emp_name

when emp_name='alex' then

concat(emp_name,'_BIGSB')

else

concat(emp_name,'SB')

end

) as new_name

from employee;

单表查询

多表查询

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值