Fixed up small sql bug