Skip to content

Instantly share code, notes, and snippets.

@seahrh
Created February 5, 2018 05:52
Show Gist options
  • Save seahrh/6bccd6f510290d30122bd97cd6f68bbd to your computer and use it in GitHub Desktop.
Save seahrh/6bccd6f510290d30122bd97cd6f68bbd to your computer and use it in GitHub Desktop.
use mydb;
set @s='pqrs';
set @d=11.11;
set @pk=15605;
INSERT INTO t1 (s,d,_fk) SELECT * FROM (SELECT @s, @d, @pk) AS tmp
WHERE NOT EXISTS (SELECT s FROM t1 WHERE s=@s and _fk=@pk) LIMIT 1;
commit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment