mysql中写if not exists报错,求大神看看

mysql 用法:1. 最常用的if not exists用法: create table if not exists AA 如果表AA不存在(返回true)则创建表 2. select 语句中使用exists, 如:select a.id,a.name from user where exists (select * from class where a.class_id = c.class_id)3. insert into中...
mysql中写if not exists报错,求大神看看
mysql中不支持if not exists 像你那样的用法
mysql 用法:
1. 最常用的if not exists用法: create table if not exists AA 如果表AA不存在(返回true)则创建表
2. select 语句中使用exists, 如:
select a.id,a.name from user where exists (select * from class where a.class_id = c.class_id)
3. insert into中使用not exists, 为了表中不插入重复语句,可以在insert into 中使用not exists进行判断,如果不存在相同的记录(not exists返回true)则插入,否则不执行,语句如下:
insert into tableA(id,name,start_time,ds)
select '1234','testName','2017-07-01 18:00:00','20170701 ' from dual WHERE not exists (select * from tableA
where instance_id = '1234' );2019-01-27
mengvlog 阅读 7 次 更新于 2025-07-20 22:56:23 我来答关注问题0
檬味博客在线解答立即免费咨询

mySQL相关话题

Copyright © 2023 WWW.MENGVLOG.COM - 檬味博客
返回顶部