Modify syntax of if statements re: sql and raw sql