Select back things that _don't_ exist

Posted by bobobobo on Stack Overflow See other posts from Stack Overflow or by bobobobo
Published on 2010-05-22T03:08:31Z Indexed on 2010/05/22 3:10 UTC
Read the original article Hit count: 308

Filed under:
|

I have this table. I want to select back the items that don't exist already, so I can create them.

table tags
+---------+-------+
| tagId   | name  |
|   1     | C     |
|   2     | DX    |
|   3     | CG    |

Say SQL looks like:

select name from tags where name in ( 'C', 'CG', 'RX' )

You get back 'C' and 'CG', so you know you have to create 'RX'.

Is there a way to get a MySQL statement like this to return 'RX' instead, when 'RX' doesn't already exist?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about select