Fixed sql query bugs
Adding the id for the last added job