Added SQL join code