如何修复')'附近的错误语法(How to fix Incorrect syntax near ')')
我试了很多但是找不到这个查询有什么问题,它给了我这个错误:
')'附近的语法不正确。
string query = "SELECT SUM(See) AS [All] , ( SELECT TOP 1 See FROM StateSite WHERE StatDate = @StatDate ) AS [Now] , ( SELECT TOP 1 See FROM StateSite WHERE StatDate = @Yesterday ) AS [Last] , ( SELECT SUM(See) FROM ( SELECT TOP 7 * FROM StateSite ORDER BY id DESC ) ) AS [week] FROM StateSite";
也适用于访问数据库,但不适用于sql server。
I tried a lot but can't find what is wrong with this query, It gave me this error:
Incorrect syntax near ')'.
string query = "SELECT SUM(See) AS [All] , ( SELECT TOP 1 See FROM StateSite WHERE StatDate = @StatDate ) AS [Now] , ( SELECT TOP 1 See FROM StateSite WHERE StatDate = @Yesterday ) AS [Last] , ( SELECT SUM(See) FROM ( SELECT TOP 7 * FROM StateSite ORDER BY id DESC ) ) AS [week] FROM StateSite";
also that works properly with access database but not by sql server.
原文:https://stackoverflow.com/questions/38568411
最满意答案
赋给form_tag方法的块不带任何参数。 错误告诉你,你的块需要一个参数,但是form_tag没有任何参数给它。 删除“| f |” 位在form_tag行的末尾,它应该工作。
The block given to the form_tag method doesn't take any parameters. The error is telling you that your block requires an argument, but form_tag doesn't have any arguments to give it. Remove the "|f|" bit at the end of the form_tag line and it should work.
相关问答
更多-
从活动记录查询接口指南 : 使用类方法是接受范围参数的首选方法。 所以你可能想要更像这样的东西: def self.latest_error_code(module_id, min, max) where( 'error_module_id = :module_id and code between :min and :max', :module_id => module_id, :min => min, :max => max ) } From the ...
-
赋给form_tag方法的块不带任何参数。 错误告诉你,你的块需要一个参数,但是form_tag没有任何参数给它。 删除“| f |” 位在form_tag行的末尾,它应该工作。 The block given to the form_tag method doesn't take any parameters. The error is telling you that your block requires an argument, but form_tag doesn't have any argum ...
-
我觉得你很亲密。 像这样的东西不会延伸到多个选项? query = Job.scoped query = query.budget_min(params[:budget_min]) if params[:budget_min] query = query.budget_max(params[:budget_max]) if params[:budget_max] @jobs = query.all I think you are close. Something like this won't exten ...
-
“:: Rails :: Engine”前的“::”是什么意思[重复](What does “::” in front of “::Rails::Engine” Mean [duplicate])[2023-11-07]
所以,雷有这个完全正确的。 我只想补充一个例子。 比方说,我们有一个名为Foo的引擎(原始的,对吧?),它安装在一个名为Bar的主机应用程序中,具有类似如下内容: #bar/config/routes.rb Rails.application.routes.draw do ... mount Foo::Engine, at: '/' ... end Foo有一个application_controller: #foo/app/controllers/foo/application_contro ... -
一个问题是update_attribute是一个实例方法。 但是你试图将它称为Pin上的类方法。 也许像这样的控制器。 def rent @pin = Pin.find(params[:id]) if @pin.update_attributes(renter_id: @user.id) #handle success else #handle failure end end 还要确保您的路线已正确设置为发布请求。 One problem is that update_at ...
-
通过Rails中的多个选择连接表的未允许参数(Unpermitted parameter for join table via multiple select in Rails)[2022-09-18]
未经许可的参数:专业 您没有设置使用该错误吐出的accept_nested_attributes_for class Expertise < ApplicationRecord has_many :specialties has_many :buckets, through: :specialties accepts_nested_attributes_for :specialties end 当我尝试这样做时,嵌套的fields_for表单不会返回任何专业,因此HTML元素为空。 然后,当我 ... -
Ruby块参数错误(Ruby block parameter error)[2023-01-18]
以下是一个稍长的示例,基于您的代码: class MyClass def test yield self end def my_own_puts s puts s end end tmp = MyClass.new tmp.test do |t| t.my_own_puts "here" end 运行此代码将输出“here”。 发生的事情是有一个方法测试可以采用一段代码,所以你可以使用do .. end语法调用它。 因为它将arg传递给yield,所以该块可用于a ... -
一个参数的多个值(multiple values from one parameter)[2023-02-20]
这里有3种方法,其中一种似乎已经发现了。 将每个部分添加为paramNN ,其中NN表示数字。 继续尝试新的NN值,直到返回null 。 使用通常不包含的字符(例如,或| )连接值,并在收到后拆分值。 使用参数值指定包含复杂数据的文件的名称。 Here are 3 ways, one of which you already seem to have discovered. Add each part as paramNN where NN represents a number. Keep trying ... -
<>是SQL语法,不是Ruby或Rails。 这意味着not equal to 。 它与Ruby中的!=基本相同。 SQL中<>一个微妙之处在于它使用NULL的行为。 在SQL中,将任何内容与NULL进行比较会得到NULL 。 比如Postgres: => select 1<>1, 1<>2, 1<>null, null<>1, null<>null; ?column? | ?column? | ?column? | ?column? | ?column? ----------+----------+- ...
-
我认为你的正则表达不太正确。 你在那里的那个将匹配2个字符,可选地后跟一个+或a , . 您还需要允许后续字符对。 试试这个正则表达式: /[a-zA-Z]{2}(\+[a-zA-Z]{2})*/ (匹配2个字符,后跟0或更多+序列,后跟2个字符)。 I think your regex isn't quite right. The one you have there will match 2 characters optionally followed by a + or a ,. You need t ...