Rails和MySQL:每个派生表必须具有自己的别名

时间:2018-06-21 10:11:57

标签: ruby-on-rails

我有这个查询:

function sortArrayUnevenFirst (array) {
    return array.sort(function(a,b){return b%2-a%2 || a-b});
}
console.log (sortArrayUnevenFirst([12,10,2,1,4,9,3,3]));
console.log (sortArrayUnevenFirst(['12','10','2','1','4','9','3','3']));

但是@imagecapturings_filter即使返回记录也没有用。

在日志中:

@imagecapturings_filter = Imagecapturing.where('kuerzel LIKE ? AND YEAR(datum_anfang) = ?', "%csg%",params[:select][:year]).page params[:page]

如果我在MySQL控制台中键入此SQL,则会得到: Processing by ImagecapturingsController#index as HTML Parameters: {"utf8"=>"✓", "select"=>{"year"=>"2018", "month"=>"all"}, "condition_field"=>"kuerzel", "predicate"=>"cont", "kuerzel"=>"csg", "submit"=>"filtern"} (5.2ms) SELECT COUNT(*) FROM (SELECT 1 FROM `imagecapturing` WHERE (kuerzel LIKE '%csg%' AND YEAR(datum_anfang) = '2018') LIMIT 150 OFFSET 0) subquery_for_count

我该如何解决? (已编辑)

0 个答案:

没有答案