Combine two integers to create a unique number

后端 未结 7 2060
北荒
北荒 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:34

    I would combine the ID like this:

    ID = ClassID * 1000 + SchoolID
    

    You can then get the SchoolID like this:

    SchoolID = ID % 1000
    

    and you can get the ClassID like this:

    ClassID = ID / 1000
    
    0 讨论(0)
提交回复
热议问题