MySQL常用查询语句积累

时间:2023-03-09 04:47:18
MySQL常用查询语句积累

>>MySQL某列插入递增值

 SET @i := 100;
UPDATE auge_item_classification SET c_code=(@i:=(@i+1));

>>MySQL查询重复记录

 SELECT id,count(id)  count FROM x_table GROUP BY id HAVING count>1

>>将一张表的数据插入到另一张表中

 1. 表结构完全一样
insert into 表1
select * from 表2
2. 表结构不一样(这种情况下得指定列名)
insert into 表1 (列名1,列名2,列名3)
select 列1,列2,列3 from 表2