If you like DNray Forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...

 

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:
SELECT
    UUID_SHORT() AS unique_index,
    language_id,
    product_id
FROM
    product_description;

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

ashutoshkumar

  •  


If you like DNray forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...