我从sqlite3查询中收到错误,但我找不到任何参考资料。谷歌搜索字符串深入我的sqlite代码本身,这是不透明的,我无法做出正面或反面。
表架构:
CREATE TABLE quote (
seqnum INTEGER,
session STRING,
timestamp_sip INTEGER,
timestamp_1 INTEGER,
market_center STRING,
symbol STRING,
bid_price INTEGER,
bid_lots INTEGER,
offer_price INTEGER,
offer_lots INTEGER,
flags INTEGER,
PRIMARY KEY (symbol, seqnum) );
查询:
select (seqnum, session, timestamp_sip, timestamp_1, market_center, symbol)
from quote
where symbol = 'QQQ';
错误:
错误:行值滥用
我不知道如何继续这里。表中有大量数据与查询匹配:
sqlite> select count(*) from quote where symbol = 'QQQ';
2675931
有人可以在这里提供任何指导吗? Sqlite版本是3.16.2。
答案 0 :(得分:36)
没关系。选择列周围的那些括号(从复制/粘贴中留下)是问题所在。可能是错误的错误信息。但是我的错。
答案 1 :(得分:1)
在使用Rails 5.2应用程序时,我遇到了类似的情况。
对于我来说,我试图为应用程序中的模型编写搜索查询:
def self.search(params)
applications = all.order('created_at DESC') # for not existing params args
applications = applications.where("cast(id as text) like ?, email like ?, first_name like ?, last_name like ?, appref like ?", "#{params[:search]}", "%#{params[:search]}%", "#{params[:search]}", "#{params[:search]}", "#{params[:search]}",) if params[:search]
applications
end
问题是我使用逗号(,
)来分隔搜索参数,我只是通过使用OR
来更正:
def self.search(params)
applications = all.order('created_at DESC') # for not existing params args
applications = applications.where("cast(id as text) like ? OR email like ? OR first_name like ? OR last_name like ? OR appref like ?", "#{params[:search]}", "%#{params[:search]}%", "#{params[:search]}", "#{params[:search]}", "#{params[:search]}",) if params[:search]
applications
end
仅此而已。
我希望这会有所帮助