Some mysql reworking