SQL generation of a unique id (int) from two fields

Started by jessepeterson, Sep 15, 2022, 01:17 AM

Previous topic - Next topic

jessepetersonTopic starter

Greetings everyone.
I'm faced with a database dilemma that involves two non-unique columns, language_id and product_id, which become unique when used together. I'm searching for a way to create a calculated field (integer) that is unique by using the values of these two non-unique columns.

One potential solution is utilizing bit shift to the left. However, I personally opted for UUID_SHORT() method to generate unique values for the calculated field.

Here's an example of how I implemented this:
    UUID_SHORT() AS unique_index,

In summary, the aim is to generate a unique calculated field from two combined non-unique columns.