From 1dfdaafc3134d68cc88757f8c3126c400389ed3b Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 3 Dec 2012 13:32:50 +0100 Subject: [PATCH] Improved SQL of own created statement. --- app/controllers/tickets_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb index 33083ca29..bff507df5 100644 --- a/app/controllers/tickets_controller.rb +++ b/app/controllers/tickets_controller.rb @@ -499,10 +499,10 @@ class TicketsController < ApplicationController # do query tickets_all = Ticket.select('DISTINCT(tickets.id)'). where(conditions). - where( '( title LIKE ? OR number LIKE ? OR ticket_articles.body LIKE ? OR ticket_articles.from LIKE ? OR ticket_articles.to LIKE ? OR ticket_articles.subject LIKE ?)', "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%" ). + where( '( `tickets`.`title` LIKE ? OR `tickets`.`number` LIKE ? OR `ticket_articles`.`body` LIKE ? OR `ticket_articles`.`from` LIKE ? OR `ticket_articles`.`to` LIKE ? OR `ticket_articles`.`subject` LIKE ?)', "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%" ). joins(:articles). limit(limit). - order('tickets.created_at DESC') + order('`tickets`.`created_at` DESC') # build result list tickets = []