可能会悲伤,但它来了。
我正在尝试对我在 Rails 中的一个子句执行 IN 操作。
电话是:
@ret = BBOrder.find(:all, :conditions => ["symbol LIKE ? AND creationDateTimeInt IN ?", "%#{symbol}%", "#{date_ints}"])
date_ints
之前作为数组创建,然后join.(', ')
在它们上面有一个。我试图只输入一个值,以测试操作
错误信息是:
BBOrder Load (2.2ms) EXEC sp_executesql N'SELECT [dbo].[BBOrders].* FROM [dbo].[BBOrders] WHERE (symbol LIKE N''%%'' AND creationDateTimeInt IN N''(20130616)'')'
ODBC::Error: 37000 (102) [unixODBC][FreeTDS][SQL Server]Incorrect syntax near '(20130616)'.: EXEC sp_executesql N'SELECT [dbo].[BBOrders].* FROM [dbo].[BBOrders] WHERE (symbol LIKE N''%%'' AND creationDateTimeInt IN N''(20130616)'')'
Completed 500 Internal Server Error in 26ms
ActiveRecord::StatementInvalid (ODBC::Error: 37000 (102) [unixODBC][FreeTDS][SQL Server]Incorrect syntax near '(20130616)'.: EXEC sp_executesql N'SELECT [dbo].[BBOrders].* FROM [dbo].[BBOrders] WHERE (symbol LIKE N''%%'' AND creationDateTimeInt IN N''(20130616)'')'):
app/controllers/pages_controller.rb:43:in `home'
有任何想法吗?
而且我不想进行原始 SQL 查询。这只会增加代码量。