SQL conditional row insert
Posted
by Pablo
on Stack Overflow
See other posts from Stack Overflow
or by Pablo
Published on 2010-05-17T21:26:08Z
Indexed on
2010/05/17
21:31 UTC
Read the original article
Hit count: 286
Is it possible to insert a new row if a condition is meet?
For example, i have this table with no primary key nor uniqueness
+----------+--------+
| image_id | tag_id |
+----------+--------+
| 39 | 8 |
| 8 | 39 |
| 5 | 11 |
+----------+--------+
I would like to insert a row if a combination of image_id and tag_id doesn't exists for example;
INSERT ..... WHERE image_id!=39 AND tag_id!=8
© Stack Overflow or respective owner