CREATE table attr ( product_id int, code varchar(50), type varchar(50) ); INSERT into attr (product_id, code, type) VALUES (1,'a','ec'), (1,'b','ec'), (1,'c','ec'), (1,'d','ec'), (1,'x','g'), (1,'y','g'), (2,'a','ec'), (3,'b','ec'), (3,'x','g') ;