本贴主要摘录一些不常见的sql语句及收藏一些好的sql写法

sql如何修改一个表的字段值等于另一个表的字段值
update confer set confer.ybp=(select ybprand.ybpid from ybprand where confer.ybp=ybprand.pid )
修改confer表中的ybp字段等于ybprand表中的ybpid (同时confer表的ybp等于ybprand表的pid)

sql删除大数量的重复数据
delete from test where name in(
select t.name from test as t
group by t.name having COUNT(t.name) > 1
)
and
id not in (
select min(b.id) from test as b
group by b.name having COUNT(b.name) > 1
) -- 除了最小的那条记录不删除,其他的都删除
 

相关文章:

  • 2021-10-10
  • 2021-04-15
  • 2021-11-28
  • 1970-01-01
  • 2021-07-31
  • 2021-09-20
  • 2021-07-19
猜你喜欢
  • 2021-12-14
  • 2021-09-13
  • 2021-07-26
  • 2021-07-12
  • 2021-06-07
相关资源
相似解决方案