scrypth for joinTable