Correct query for primary key