SQL quieries modified to make user_id and ids not interfere with each other