一个问题请教一下:
如一个表有10个栏位,想取出这10个栏位的唯一值,则sql这样写的
select distinct col1 from test_table;
select distinct col2 from test_table;
select distinct col3 from test_table;
select distinct col4 from test_table;
...
目前的情况是这个表比较大,进行10次的distinct对负载有很大影响,有没有好的办法?
如一个表有10个栏位,想取出这10个栏位的唯一值,则sql这样写的
select distinct col1 from test_table;
select distinct col2 from test_table;
select distinct col3 from test_table;
select distinct col4 from test_table;
...
目前的情况是这个表比较大,进行10次的distinct对负载有很大影响,有没有好的办法?
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/271283/viewspace-419100/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/271283/viewspace-419100/