When you make a field unique, it can only be inserted once. Is there a way to make two fields unique when they are used together or is there an SQL syntax that would allow me to do that?

I have a userID and an itemNr. Users can have as many item numbers as they want and currently they simply get inserted. This means I cannot set them UNIQUE.

However, I want to prevent that the same combination is in the DB twice.

I know how to do it programmatically (first select an item, then check if it matches the one you want to insert, if so, update it).

Is there a more elegant way using direct SQL syntax? I use MySQL.