# Dropdown list SQL query problem

**URL:** <https://forum.inductiveautomation.com/t/dropdown-list-sql-query-problem/8970>\
**Category:** Ignition\
**Created:** [August 28, 2014, 9:41am UTC](https://forum.inductiveautomation.com/t/dropdown-list-sql-query-problem/8970 "2014-08-28T09:41:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tumeksi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tumeksi/32/4697_2.png) [@Tumeksi](https://forum.inductiveautomation.com/u/Tumeksi)\
**Post date:** [August 28, 2014, 9:41am UTC](https://forum.inductiveautomation.com/t/dropdown-list-sql-query-problem/8970/1 "2014-08-28T09:41:42Z")

</div>

Hi!

Sorry if this has already been asked and answered, but I tried to search an answer on the forums.

I’m having a small problem with the Dropdown list.  
I have created a table which has one column for users roles and other one for a plain language name for the Project that specific role responses to. I.E. Role User1 is for project 1 and user2 is for project 2 and so on.

I’m using the following SQL query in the dropdown list: “SELECT project FROM project\_userroles WHERE role IN (’{[System]Client/User/RolesString}’)”

This works when the User has only one role, but the list is empty if there are Two or more roles for the user. I tried to replace the RolesString with RolesDataSet but that just gives me a plank list in all occasions.

How can i get this to work?

What I’m trying to do is make a dropdown list with all of the users Projects and the user selects the project he wants and the is redirected to the selected project. This works when the user has only one Role, as i mentioned above.

---

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [August 28, 2014, 1:43pm UTC](https://forum.inductiveautomation.com/t/dropdown-list-sql-query-problem/8970/2 "2014-08-28T13:43:25Z")

</div>

Assuming that the client tag has comma separated roles in it, the actual SQL query would be similar to this:

```auto
SELECT project FROM project_userroles WHERE role IN ('Role_1,Role_2,Role_3')
```

It needs to be:

```auto
SELECT project FROM project_userroles WHERE role IN ('Role_1','Role_2','Role_3')
```

Possible solution - add a custom property to your root container and populate it with the user roles from the client tag formatted in the correct way. Then use the custom property in the binding instead of the client tag.

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [August 29, 2014, 12:48pm UTC](https://forum.inductiveautomation.com/t/dropdown-list-sql-query-problem/8970/3 "2014-08-29T12:48:48Z")

</div>

Try using this expression in the custom property as suggested:

```auto
replace({[System]Client/User/RolesString},",","','")
```

---

<div class="post-metadata">

**Author:** ![Tumeksi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tumeksi/32/4697_2.png) [@Tumeksi](https://forum.inductiveautomation.com/u/Tumeksi)\
**Post date:** [September 1, 2014, 11:59am UTC](https://forum.inductiveautomation.com/t/dropdown-list-sql-query-problem/8970/4 "2014-09-01T11:59:32Z")

</div>

Hi!

Thank You!  
I got it to work.  
I used the replace-expression for a custom property.  
Then I added the property to the SQL-query.

Works nicely!
