Fixed SQL search bug