# Select statement where row id from a table = -1

**URL:** <https://forum.inductiveautomation.com/t/select-statement-where-row-id-from-a-table-1/10104>\
**Category:** Ignition\
**Created:** [June 8, 2015, 5:14pm UTC](https://forum.inductiveautomation.com/t/select-statement-where-row-id-from-a-table-1/10104 "2015-06-08T17:14:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MoisesZV](https://avatars.discourse-cdn.com/v4/letter/m/e68b1a/32.png) [@MoisesZV](https://forum.inductiveautomation.com/u/MoisesZV)\
**Post date:** [June 8, 2015, 5:14pm UTC](https://forum.inductiveautomation.com/t/select-statement-where-row-id-from-a-table-1/10104/1 "2015-06-08T17:14:53Z")

</div>

Hi, I have a power table with a custom propertie named “fila” binded to the selected row of the table. Then I have a textbox with this sql query:

```auto

SELECT centro_maquina FROM partidas_paradas WHERE id = {Root Container.Power Table.fila}

```

When I select a row this statement return “centro\_maquina” from “partidas\_paradas” where id equals the selected row.

The problem happen when there is not a row selected, the id equals -1 then there is 0 records returned and I get errors.

How can I solve this?

---

<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:** [June 8, 2015, 5:53pm UTC](https://forum.inductiveautomation.com/t/select-statement-where-row-id-from-a-table-1/10104/2 "2015-06-08T17:53:25Z")

</div>

You could enable the “Fallback Value” on the SQL Query binding and provide a fall back value.

Best,

---

<div class="post-metadata">

**Author:** ![MoisesZV](https://avatars.discourse-cdn.com/v4/letter/m/e68b1a/32.png) [@MoisesZV](https://forum.inductiveautomation.com/u/MoisesZV)\
**Post date:** [June 8, 2015, 6:16pm UTC](https://forum.inductiveautomation.com/t/select-statement-where-row-id-from-a-table-1/10104/3 "2015-06-08T18:16:13Z")

</div>

That was so easy! thanks again nmudge, sorry for asking so many questions.

---

<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:** [June 8, 2015, 6:24pm UTC](https://forum.inductiveautomation.com/t/select-statement-where-row-id-from-a-table-1/10104/4 "2015-06-08T18:24:18Z")

</div>

MoisesZV,

It is quite all right. Questions is what the forum is for. Ask as many questions as you like.

Best,
