Improved SQL of own created statement.
This commit is contained in:
parent
144196ce9a
commit
1dfdaafc31
1 changed files with 2 additions and 2 deletions
|
@ -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 = []
|
||||
|
|
Loading…
Reference in a new issue