# Dropdown SQL QUERY duplicates

**URL:** <https://forum.inductiveautomation.com/t/dropdown-sql-query-duplicates/39661>\
**Category:** Ignition\
**Created:** [October 14, 2020, 2:36pm UTC](https://forum.inductiveautomation.com/t/dropdown-sql-query-duplicates/39661 "2020-10-14T14:36:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![steven.cox](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/steven.cox/32/18589_2.png) [@steven.cox](https://forum.inductiveautomation.com/u/steven.cox)\
**Post date:** [October 14, 2020, 2:36pm UTC](https://forum.inductiveautomation.com/t/dropdown-sql-query-duplicates/39661/1 "2020-10-14T14:36:36Z")

</div>

Hi all,

I have a dropdown bound to this query…

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/0/808702ad037bca84bbf384adb925555deff6335c.png)

Select\_binder is another dropdown.

The query selects the correct row from binder\_topics, but it displays it 7 times…

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/6/a68d920da4a7bea3bd9f596dbcdf3085c1455b97.png)

The tables are:

binder\_names  
id  
binder\_name

binder\_topics  
id  
topic\_name  
binder\_id

Is this an issue with the query (what I am guessing), or maybe something else? 7 times is the exact number of entries in the binder\_names table so I am sure this is a query issue.

Thanks for the help,

Steven

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [October 14, 2020, 2:43pm UTC](https://forum.inductiveautomation.com/t/dropdown-sql-query-duplicates/39661/2 "2020-10-14T14:43:34Z")

</div>

I would assume it is your query. I would think it should be more like:

```auto
SELECT bt.id
	,bn.topic_name
FROM binder_topics bt
JOIN binder_names bn
	ON bt.id = bn.binder_id
WHERE bn.binder_id = {Root Container.select_binder.selectedValue}

```

---

<div class="post-metadata">

**Author:** ![Funguy](https://avatars.discourse-cdn.com/v4/letter/f/58f4c7/32.png) [@Funguy](https://forum.inductiveautomation.com/u/Funguy)\
**Post date:** [October 14, 2020, 2:53pm UTC](https://forum.inductiveautomation.com/t/dropdown-sql-query-duplicates/39661/3 "2020-10-14T14:53:29Z")

</div>

Hey Steve,

The Join tells the query how to join. The selected value goes into a WHERE clause. Something like this:

SELECT binder\_topics.id, binder\_topics.topic\_name  
FROM binder\_topics  
JOIN binder\_names ON binder\_topics.binder\_id = binder\_names,id  
WHERE {Root Container.selectselect\_binder.selectedValue} = binder\_topics.binder\_id

Hope that helps!

Cheers, Sean

---

<div class="post-metadata">

**Author:** ![steven.cox](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/steven.cox/32/18589_2.png) [@steven.cox](https://forum.inductiveautomation.com/u/steven.cox)\
**Post date:** [October 14, 2020, 2:58pm UTC](https://forum.inductiveautomation.com/t/dropdown-sql-query-duplicates/39661/4 "2020-10-14T14:58:09Z")

</div>

@bpreston & @Funguy,

Thank y’all!! I thought there should have been a WHERE clause but was trying to replace the ON. I see now the relationship.

I still have a question on JOINS in general. I understand the relationships of INNER, RIGHT, LEFT, & OUTER, but when you talk about RIGHT & LEFT, how do you define which table is the RIGHT or LEFT table?

is it the FROM table? This has always eluded me and all I read does not seem to really define it.

Again, thanks for the help and education.

Steven

---

<div class="post-metadata">

**Author:** ![Funguy](https://avatars.discourse-cdn.com/v4/letter/f/58f4c7/32.png) [@Funguy](https://forum.inductiveautomation.com/u/Funguy)\
**Post date:** [October 14, 2020, 3:04pm UTC](https://forum.inductiveautomation.com/t/dropdown-sql-query-duplicates/39661/5 "2020-10-14T15:04:08Z")

</div>

Hey Steve,

The LEFT table is the one after FROM. The RIGHT is one after JOIN.

Cheers, Sean

---

<div class="post-metadata">

**Author:** ![steven.cox](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/steven.cox/32/18589_2.png) [@steven.cox](https://forum.inductiveautomation.com/u/steven.cox)\
**Post date:** [October 14, 2020, 3:08pm UTC](https://forum.inductiveautomation.com/t/dropdown-sql-query-duplicates/39661/6 "2020-10-14T15:08:36Z")

</div>

> [@Funguy](#):
>
> The LEFT table is the one after FROM. The RIGHT is one after JOIN.

That's what I was looking for. and its easy to remember going from left to right.

Thanks @Funguy

Steven
