如何使用GROUP_CONCAT在WebSql中准备语句

时间:2015-06-17 20:58:30

标签: mysql sqlite web-sql

如何将此MySql预处理语句更改为WebSql查询语句

"SELECT a.id,a.title, CONCAT('[', GROUP_CONCAT( CONCAT('{"id":',b.id,', "name":"',b. `name`,'", "number":"',b.number,'"}') ORDER BY b.name), ']')AS people FROM contact_group AS a LEFT JOIN contact_list AS b ON a.id = b.gID GROUP BY a.id, a.title"

这是我的完整查询

function fetchContactGroup(){
db.transaction (function(tx){
        tx.executeSql("SELECT a.catID, a.title, ||('[', GROUP_CONCAT( ||('{""id"":',b.id,', ""name"":"',b. name,'", ""number"":"',b.number,'"}') ORDER BY b.name), ']')AS people FROM CONTACTGROUP AS a LEFT JOIN ALERTCONTACT AS b ON a.catID = b.catID", [], function (tx, results) {                 
                var len = results.rows.length;
                var output_results = [];
                for (var i=0; i<len; i++){
                   output_results[i] = results.rows.item(i);
                }
                    $scope.$apply(function(){
                        $scope.cGft = output_results; 
                    })
        },function(tx, error) {
                console.log(error.message);
                 })
    })
}

我已尽我所能,但它仍然给我错误。

如果有人能帮助我或指出我正确的方向,我会很高兴。

0 个答案:

没有答案