Use mid instead of public_key in sql select.