# Problem with system.db.runquery

**URL:** <https://forum.inductiveautomation.com/t/problem-with-system-db-runquery/10291>\
**Category:** Ignition\
**Created:** [July 29, 2015, 6:41pm UTC](https://forum.inductiveautomation.com/t/problem-with-system-db-runquery/10291 "2015-07-29T18:41:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrea.montresor](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@andrea.montresor](https://forum.inductiveautomation.com/u/andrea.montresor)\
**Post date:** [July 29, 2015, 6:41pm UTC](https://forum.inductiveautomation.com/t/problem-with-system-db-runquery/10291/1 "2015-07-29T18:41:13Z")

</div>

Hello,  
I’m trying to make a script system.db.runquery. This is my code:

`table = system.db.runQuery("SELECT * FROM adm_supplier","dscada_main")
value= 'test'
for row in table:
	if(value == row["ID_SUPPLIER"]):
		print 'ok'
	else:
		print 'no'`

The output is this:  
no  
ok  
no  
no

The output is correct because I have one line that is ‘test’ while others no.  
I want that when the value is present in a row I return ‘ok’, otherwise ‘no’.  
It now returns all four lines, but I want you back only a line saying ‘ok’ if it exists, otherwise ‘no’  
How can I fix?

Thanks

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [July 29, 2015, 6:47pm UTC](https://forum.inductiveautomation.com/t/problem-with-system-db-runquery/10291/2 "2015-07-29T18:47:43Z")

</div>

Here you go:

```auto
table = system.db.runQuery("SELECT * FROM adm_supplier","dscada_main")
if 'test' in [row["ID_SUPPLIER"] for row in table]:
	print 'ok'
else:
	print 'no'
```

Best,

---

<div class="post-metadata">

**Author:** ![andrea.montresor](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@andrea.montresor](https://forum.inductiveautomation.com/u/andrea.montresor)\
**Post date:** [July 29, 2015, 6:55pm UTC](https://forum.inductiveautomation.com/t/problem-with-system-db-runquery/10291/3 "2015-07-29T18:55:45Z")

</div>

Thank you so much!

Andrea
