Updated SQL to use 'key' instead of 'attribute'