I have a large mysql table (500,000 records). I need to find sets of data that have all the same attributes (KEY, NAME AND VALUE). Some sets have 20 attributes others have 397 per each KEY. The table looks like this. KEY is a foreign key.
ID, KEY, NAME, VALUE 1 87 Color Red 2 87 Size Big 3 87 Weight 6 4 85 Color Red 5 85 Size Big 6 85 Weight 6 7 96 Color Red 8 96 Size Small 8 96 Weight 7
I'm trying to write a query where if KEY=87 it finds KEY 85 matches all attributes and values like KEY 87. There are 397 different attributes rather than just the 3 I show here. I can do this in php but it's sloppy and I want to learn more about mysql but I can't get my head around it. Appreciate any help in advance.