fix baaaaaad sql