sql - How to generate combinations -


i have requirement create table identifier column. identifier data comprised of 3 parts, first being letter [a-z], second being number [1-42] , third being again number [1-6].

i wondering quickest , best way go i'm stuck. output should this:

a-1-1 a-1-2 a-1-3 ... z-42-6 

thanks help

you should use cross join derived tables containing letters/numbers needed

select letters.let + '-' + numbers.num + '-' + numbers2.num from(select 'a' let union select 'b' .....) letters cross join(select '1' num union select '2' ....) numbers -- 42 cross join(select '1' num union select '2' ....) numbers2 -- 6 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -