How to prepared statement in WebSql with GROUP_CONCAT

552 views Asked by At

How do I change this MySql prepared statement into WebSql query statement

"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"

This is my complete query

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);
                 })
    })
}

I have done everything I could but it is still giving me error.

I will be glad if anyone can help me or point me in the right direction.

0

There are 0 answers