N
N
Nursultan I am2018-10-24 21:59:09
MySQL
Nursultan I am, 2018-10-24 21:59:09

How to make MySQL unique field with exception?

Good day.
There is a table:

id| name
0 | Book
0 | Video
11| Game
12| Movie
13| Story

How to make the ID field unique but with an exception that 0can be repeated?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2018-10-24
@nursultanya

If id is the primary key, then no way.
If just a unique field, then use NULL instead of zero.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question