sql 语句

批量插入数据:

insert into actor(actor_id,first_name,last_name,last_update)
values(1,'PENELOPE','GUINESS','2006-02-15 12:34:33'),
(2,'NICK','WAHLBERG','2006-02-15 12:34:33');

删除emp_no重复的记录,只保留最小的id对应的记录。

CREATE TABLE IF NOT EXISTS titles_test (
id int(11) not null primary key,
emp_no int(11) NOT NULL,
title varchar(50) NOT NULL,
from_date date NOT NULL,
to_date date DEFAULT NULL);

delete 
from  titles_test 
where id not in (
    select min(id) from titles_test
    group by emp_no
)

sql 更新操作

update titles_test
set  from_date = '2001-01-01',to_date = NULL
where to_date = '9999-01-01'

 

原文地址:https://www.cnblogs.com/lijins/p/10349893.html