l******9 发帖数: 579 | 1 【 以下文字转载自 JobHunting 讨论区 】
发信人: light009 (light009), 信区: JobHunting
标 题: generate unique integer ID from columns in SQL table
发信站: BBS 未名空间站 (Fri Nov 14 17:36:46 2014, 美东)
I need to generate a new column in a table in a sql database.
the given table is:
id1 value1 value2 value3 value4
9465 387 801 1990 20
All columns are integer. All columns are integer. value1 and value2 are
always 3 digits, value3 are year value, value4 is not more than 3 digits.
I need to generate a value by combining value1 to value4, suppose that it is
called "value_combine". The "value_combine" should be unique. For example,
given the different combinations of value1 to value4, the "value_combine"
should also be different.
And then, the "value_combine" is combined with id1 such that the new value (
we call it final_id) should be unique.
For example, given different combinations of id1 and value_combine, the
final_id should also be different.
The final_id can be used to identify each unique combination of id1 and
value1-4.
The final_id MUST be integer and all values should have the same length of
digits, such as 6, 7 or 8 digits.
Any help would be appreciated. |
|