Fix search SQL