mysql> truncate a1; Query OK, 0 rows affected (0.01 sec) mysql> INSERT INTO `a1` (id,v1) SELECT 1, 'data' FROM DUAL WHERE not exists (select * from a1 where id = 1); Query OK, 1 row affected (0.00 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> INSERT INTO `a1` (id,v1) SELECT 1, 'data' FROM DUAL WHERE not exists (select * from a1 where id = 1); Query OK, 0 rows affected (0.00 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> select * from a1; +------+------+ | id | v1 | +------+------+ | 1 | data | +------+------+ 1 row in set (0.00 sec) mysql> |
INSERT INTO `ipinfo` (Ip_Address,Mac_Address) SELECT '192.168.0.1', '00:00:00:00:00:00' FROM DUAL WHERE not exists (select * from 'ipinfo' where Ip_Address = '192.168.0.1'); |
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |