I have table1
, which has
我有table1,它有
MBID | Artist
__________________
123321 The Beatles
123214 Led Zeppelin
123321 The Beatles
How can I copy all of the distinct MBID's
along with their corresponding Artist
name, into a new table, so that the new table only has distinct MBID
's
如何将所有不同的MBID及其相应的艺术家名称复制到新表中,以便新表只有不同的MBID
MBID | Artist
__________________
123321 The Beatles
123214 Led Zeppelin
I've tried
我试过了
insert into table2 (MBID,artist)
select distinct(table1.MBID),table1.artist
FROM danktable
But this gives me weird combinations and not only distinct MBID's
但这给了我奇怪的组合,而不仅仅是不同的MBID
When I make the MBID
a primary index, I get an error with this query because i'm getting non-unique MBID
values.
当我将MBID作为主索引时,我得到了这个查询的错误,因为我得到了非唯一的MBID值。
Could someone help me out?
有人可以帮帮我吗?
Thanks !
谢谢 !
1 个解决方案
#1
3
You can do it as follows :
你可以这样做:
insert into table2 (MBID,artist)
select MBID,max(artist)
from table1
group by MBID
#1
3
You can do it as follows :
你可以这样做:
insert into table2 (MBID,artist)
select MBID,max(artist)
from table1
group by MBID