# Ionic 2 SqlStorage iOS SELECT doesn't return data

**URL:** <https://forum.ionicframework.com/t/ionic-2-sqlstorage-ios-select-doesnt-return-data/61833>\
**Category:** ionic-v3\
**Created:** [August 28, 2016, 2:37pm UTC](https://forum.ionicframework.com/t/ionic-2-sqlstorage-ios-select-doesnt-return-data/61833 "2016-08-28T14:37:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefanleever](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/stefanleever/32/102734_2.png) [@stefanleever](https://forum.ionicframework.com/u/stefanleever)\
**Post date:** [August 28, 2016, 2:37pm UTC](https://forum.ionicframework.com/t/ionic-2-sqlstorage-ios-select-doesnt-return-data/61833/1 "2016-08-28T14:37:37Z")

</div>

I’ve recently started developing an app using Ionic 2 because of it’s out-of-the-box support of SqlStorage.

The SqlStorage implementation works great for Ionic Serve and the Android Emulator but not on iOS.

The SqlStorage implementation on iOS works to the point where you can create the tables and insert some data but I can’t seem to retrieve any data with a simple SELECT statement such as:

```
storage.query('SELECT * FROM box WHERE boxHidden = ?', [0]).then((resp) => {
   console.log(JSON.stringify(resp));
});

```

From this query I am only getting back the following resultset:

```
{
"tx": {
	"db": {
		"openargs": {
			"name":"__ionicstorage",
			"location":2,
			"createFromLocation":0,
			"backupFlag":2,
			"existingDatabase":false,
			"dblocation":"nosync"
		},
	"dbname":"__ionicstorage"
	},
	"txlock":true,
	"readOnly":false,
	"executes":[],
	"finalized":true
},
"res": {
	"rows": {
		"length":3
	},
	"rowsAffected":0
}
}

```

As opposed to Android where I am getting a resultset with an arraly of data with 3 objects and the length element.

Has anybody got a similar experience and knows how to approach/solve this?

Thank you very much in advance.

Best regards,

---

<div class="post-metadata">

**Author:** ![mmalaka](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@mmalaka](https://forum.ionicframework.com/u/mmalaka)\
**Post date:** [August 30, 2016, 9:16pm UTC](https://forum.ionicframework.com/t/ionic-2-sqlstorage-ios-select-doesnt-return-data/61833/2 "2016-08-30T21:16:09Z")

</div>

I am getting similar issue…did u managed to fix this?

---

<div class="post-metadata">

**Author:** ![mikewagz](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mikewagz/32/93786_2.png) [@mikewagz](https://forum.ionicframework.com/u/mikewagz)\
**Post date:** [August 30, 2016, 11:05pm UTC](https://forum.ionicframework.com/t/ionic-2-sqlstorage-ios-select-doesnt-return-data/61833/3 "2016-08-30T23:05:05Z")

</div>

I use `resp.res.rows` and `resp.res.rows.item(x)` to get the data across all devices.

---

<div class="post-metadata">

**Author:** ![stefanleever](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/stefanleever/32/102734_2.png) [@stefanleever](https://forum.ionicframework.com/u/stefanleever)\
**Post date:** [September 2, 2016, 9:52pm UTC](https://forum.ionicframework.com/t/ionic-2-sqlstorage-ios-select-doesnt-return-data/61833/4 "2016-09-02T21:52:27Z")

</div>

Thanks, that was the answer I was going to type if nothing was here yet.

In order to receive the data for the rows in iOS (and Android as well) you **always** need to use the resp.res.rows.item(x) function by looping through the results (resp.res.rows.length) with a for-loop.

When using that function you can use resp.res.rows.item(x).fieldName to fetch the fields returned by the result-set.
