Combine two integers to create a unique number

后端 未结 7 2072
北荒
北荒 2020-12-10 02:05

Good Morning,

I was looking for a way to combine two integers to create a unique number, I have two tables that I need to combine into a third table with unique numb

7条回答
  •  一向
    一向 (楼主)
    2020-12-10 02:31

    You indicate that you are working with a table. This leads me to believe that you are working within a database.

    So I have to ask, why not store them in separate columns and make them simple foreign keys? Why create the ambiguity of trying to concatenate or transform the numbers with a math equation?

    If you use another table, you can use an auto increment field and the combination of the three fields (in the order you designate) will give you a unique ID.

    |-------------------
    | My_combine_table
    |-------------------
    | id   | auto_inc 
    |-------------------
    | SchoolID | ...
    | SchoolID2 | ...
    

提交回复
热议问题