# IF ,Select statement error

**URL:** <https://forum.inductiveautomation.com/t/if-select-statement-error/16388>\
**Category:** Ignition\
**Created:** [December 21, 2017, 10:26am UTC](https://forum.inductiveautomation.com/t/if-select-statement-error/16388 "2017-12-21T10:26:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tamerplc](https://avatars.discourse-cdn.com/v4/letter/t/d78d45/32.png) [@tamerplc](https://forum.inductiveautomation.com/u/tamerplc)\
**Post date:** [December 21, 2017, 10:26am UTC](https://forum.inductiveautomation.com/t/if-select-statement-error/16388/1 "2017-12-21T10:26:24Z")

</div>

I have this SQL query  
`SELECT Allocation_State FROM allocation_state where ws_cur_mode={Root Container.Tabel1.AllocationSate_F} IF ({Root Container.Dropdown.selectedValue}>0)`

**i received below error**

```auto
java.lang.Exception: Error running query:
SQLQuery(query=SELECT Allocation_State FROM allocation_state where ws_cur_mode=1 IF (1>0)
, database=)@0ms
On: Main Window.Root Container.AllocationState 2.text

```

---

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [December 21, 2017, 11:32am UTC](https://forum.inductiveautomation.com/t/if-select-statement-error/16388/2 "2017-12-21T11:32:30Z")

</div>

What are you trying to achieve? `IF` isn’t a selector on it’s own (in most SQL dialects at least), it’s always used to get something back.

The standard way to check some condition in SQL is via the `WHERE` clause, which is already in your query. So you perhaps just need to do  
`WHERE ws_cur_mode=1 AND {Root Container.Dropdown.selectedValue}>0`

But it all depends on what you want to get back from the query.

---

<div class="post-metadata">

**Author:** ![tamerplc](https://avatars.discourse-cdn.com/v4/letter/t/d78d45/32.png) [@tamerplc](https://forum.inductiveautomation.com/u/tamerplc)\
**Post date:** [December 23, 2017, 12:10pm UTC](https://forum.inductiveautomation.com/t/if-select-statement-error/16388/3 "2017-12-23T12:10:21Z")

</div>

Thanks a lot Sanderd\>\>\> I used where&AND and it’s working now  
Thanks
