insert if not exists
2012-10-22 23:56
246 查看
示例一:插入多条记录
假设有一个主键为 client_id 的 clients 表,可以使用下面的语句:
INSERTINTOclients(client_id, client_name, client_type)SELECTsupplier_id, supplier_name, 'advertising'FROMsuppliersWHEREnotexists(select * fromclientswhereclients.client_id = suppliers.supplier_id);
示例一:插入单条记录
INSERTINTOclients(client_id, client_name, client_type)SELECT10345, 'IBM', 'advertising'FROMdualWHEREnotexists(select * fromclientswhereclients.client_id = 10345);
假设有一个主键为 client_id 的 clients 表,可以使用下面的语句:
INSERTINTOclients(client_id, client_name, client_type)SELECTsupplier_id, supplier_name, 'advertising'FROMsuppliersWHEREnotexists(select * fromclientswhereclients.client_id = suppliers.supplier_id);
示例一:插入单条记录
INSERTINTOclients(client_id, client_name, client_type)SELECT10345, 'IBM', 'advertising'FROMdualWHEREnotexists(select * fromclientswhereclients.client_id = 10345);
相关文章推荐
- INSERT INTO IF NOT EXISTS(插入集合)
- mysql防止重复插入相同记录 insert if not exists
- MySQL 当记录不存在时插入(insert if not exists)
- mysql insert if not exists防止插入重复记录的方法
- mysql insert if not exists防止插入重复记录的方法
- mysql insert if not exists防止插入重复记录的方法
- my sql insert if not exists 的方法
- mysql insert if not exists防止插入重复记录的方法(转)
- MySQL 当记录不存在时插入insert if not exists
- mysql insert if not exists
- mysql insert if not exists防止插入重复记录的方法
- mysql5.7基础 create database if not exists... 判断数据库是否存在 若不存在则创建
- table if not exists
- # mysql CREATE TABLE IF NOT EXISTS metadata lock坑
- add column for a table if this column not exists using T-SQL in SQLServer
- Oracle database does not have a "drop table if exists" clause
- mysql的CREATE TABLE IF NOT EXISTS 方法
- android sqlite 中 创建表 不要使用 "IF NOT EXISTS " + TABLE_NAME;
- SQL: If Exists Update Else Insert
- mysql的CREATE TABLE IF NOT EXISTS 方法