如何执行复杂的sql语句并在数组中获取结果?(How to execute a complex sql statement and get the results in an array?)
我想使用SQLite.swift执行一个相当复杂的SQL语句,并将结果最好放在一个数组中,以用作tableview的数据源。 声明如下:
SELECT defindex, AVG(price) FROM prices WHERE quality = 5 AND price_index != 0 GROUP BY defindex ORDER BY AVG(price) DESC
我正在研究SQLite.swift文档,以了解如何正确地完成它,但我找不到办法。 我可以在数据库上调用prepare并遍历Statement对象,但这不是最佳的性能。
任何帮助,将不胜感激。
I would like to execute a fairly complex SQL statement using SQLite.swift and get the result preferably in an array to use as a data source for a tableview. The statement looks like this:
SELECT defindex, AVG(price) FROM prices WHERE quality = 5 AND price_index != 0 GROUP BY defindex ORDER BY AVG(price) DESC
I was studying the SQLite.swift documentation to ind out how to do it properly, but I couldn't find a way. I could call prepare on the database and iterate through the Statement object, but that wouldn't be optimal performance wise.
Any help would be appreciated.
原文:https://stackoverflow.com/questions/29986270
满意答案
你只需声明你的
List<moviemodel>moviemodelList = new ArrayList<>();
在asynctask中使用相同的列表,并且在两个asynctask中使用相同的列表。如果使用在asynctask中声明列表,它将重新初始化,并且从第一个asynctask存储的以前的数据将从列表中清除。只需声明您在create方法之上声明所有变量的列表。
you just Declare your
List<moviemodel>moviemodelList = new ArrayList<>();
out of the asynctask and used the same list in both asynctask.If you use declare the list inside asynctask it re-initialized and the previous data which store from first asynctask clear from list.Just declare the list where you declare all variable above the create method.
相关问答
更多解析多个JSON URL(parsing Multiple JSON Url)
Json从网址解析(Json Parsing from url)
从JSON快速解析多个图像(Parsing multiple images in swift from JSON)
使用PHP从URL解析JSON(Parsing JSON from URL with PHP)
Android JSON从URL解析(Android JSON Parsing from URL)
从url获取json并解析信息(Get json from url and parsing information)
JSON使用此URL解析Swift In Swift(JSON Parsing In Swift with this URL)
使用URL解析JSON与Python(Parsing JSON with Python from URL)
Android JSON解析URL(Android JSON Parsing URL)
在Java中解析来自url的JSON(Parsing JSON from url in Java)
相关文章
更多JDBC系列教程之四:SQL注入PreparedStatement和Statement
SQL Server 压力测试
sql问题
Sql Support within Solr-类Sql的solr搜索实现(1)
Solrflux源码分析-Sql Support within Solr-类Sql的solr搜索实现(2)
Becoming a data scientist
一个sql查询
关于mysql 的 sql
请教一个SQL实现
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!