# Determine if row exists in a table

**URL:** <https://community.glideapps.com/t/determine-if-row-exists-in-a-table/35491>\
**Category:** Ask for Help\
**Created:** [December 3, 2021, 9:27pm UTC](https://community.glideapps.com/t/determine-if-row-exists-in-a-table/35491 "2021-12-03T21:27:50Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Gabler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david_gabler/32/44332_2.png) [@David\_Gabler](https://community.glideapps.com/u/David_Gabler)\
**Post date:** [December 3, 2021, 9:27pm UTC](https://community.glideapps.com/t/determine-if-row-exists-in-a-table/35491/1 "2021-12-03T21:27:50Z")

</div>

Hi, I have a column that I use as a relational “multiple select” and it works fine. Why can’t I interrogate that field in the current row to see if a value already exists? I am trying to avoid writing duplicate records. I have it populated with the Row ID of another table (by using relations). Is there another way to avoid writing duplicates to this secondary table?

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [December 4, 2021, 12:42am UTC](https://community.glideapps.com/t/determine-if-row-exists-in-a-table/35491/2 "2021-12-04T00:42:32Z")

</div>

We would need more screenshots from you to know how you are setting it up.

Normally, if I want to check if a value is duplicated or not, I use a custom form, then create a relation from the input field to the list of existing values. If the relation is not empty, that means there’s a duplicate and we should not allow a form submission.

> [@How do I create a custom form?](https://community.glideapps.com/t/how-do-i-create-a-custom-form/25014/1):
>
> I’m just dropping this here so I have something to refer people to when they ask. This is a simple concept app (copyable), that demonstrates the following techniques: Building custom forms for adding and editing list items (as an alternative to the native forms provided by Glide) Preventing duplicate new entries using [User Specific Columns](https://docs.glideapps.com/all/reference/data-editor/user-specific-columns) and [Relations](https://docs.glideapps.com/all/reference/data-editor/computed-columns/relation-column) Enforcing mandatory input items The use of visibility conditions and user specific booleans to control user flow There is nothing particula…

---

<div class="post-metadata">

**Author:** ![David\_Gabler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david_gabler/32/44332_2.png) [@David\_Gabler](https://community.glideapps.com/u/David_Gabler)\
**Post date:** [December 4, 2021, 2:20am UTC](https://community.glideapps.com/t/determine-if-row-exists-in-a-table/35491/3 "2021-12-04T02:20:32Z")

</div>

Hi, well, I did that, but it only allows me to check for IS EMPTY or IS NOT EMPTY. I really need to check IF CONTAINS to the relation field. Here is the check…  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/7/2/72900ef0b5e333a16fb532358e00efc45bf83756.png)

And here is the relation field. This seems to work OK. I don’t want the same people to click the ADD ROW button twice.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/1/5/15de2a623b36cd2ddefb4e5e2f89e2956081b7d5.png)

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [December 4, 2021, 2:31am UTC](https://community.glideapps.com/t/determine-if-row-exists-in-a-table/35491/4 "2021-12-04T02:31:45Z")

</div>

Which value are you using to build the relation?

If your target table contains the email address - which seems to be the case - and you’re trying to prevent duplicate entries from the same user, then your relation should be formed by joining the email address of the signed in user with the email address column in the target table.

Actually, if I’m understanding your use case correctly, you don’t even need a custom form. Just add this relation column to your User Profiles table, and if it’s not empty then don’t even show the Add Entry button in the first place.

---

<div class="post-metadata">

**Author:** ![David\_Gabler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david_gabler/32/44332_2.png) [@David\_Gabler](https://community.glideapps.com/u/David_Gabler)\
**Post date:** [December 4, 2021, 2:46am UTC](https://community.glideapps.com/t/determine-if-row-exists-in-a-table/35491/5 "2021-12-04T02:46:08Z")

</div>

Well, here is the Row ID from the “Intentions” table:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/8/a/8af2cd14ae4e701fd8c74a2e328a3fa5106a3ab7.png)  
And here is the “Intentions Row ID” from the “Prayed For” table:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/e/c/ecc1b3a0965e1ff7c9349e0cb20f09a675becf27.png)  
So, to your point, I am not sure why it is showing the email address in the relation column. You can see I am using the two Row ID columns as the relation. At any rate, the User table really has nothing to do with it. The same user can click the “Pray for” button on each intention, but I don’t want them to be able to click it twice on the SAME intention. Right now they can.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [December 4, 2021, 3:05am UTC](https://community.glideapps.com/t/determine-if-row-exists-in-a-table/35491/6 "2021-12-04T03:05:03Z")

</div>

> [@David\_Gabler](#):
>
> So, to your point, I am not sure why it is showing the email address in the relation column.

That doesn’t really mean anything other than telling you that the relation is not empty.

> [@David\_Gabler](#):
>
> The same user can click the “Pray for” button on each intention, but I don’t want them to be able to click it twice on the SAME intention. Right now they can.

Okay, what you need to do is create a template column in your Intentions table that joins the intention ID and user email address columns. Then build a similar template column using the selected intention ID and signed in users email address. Then use those two columns to build your relation. If it’s not empty, then you have a potential duplicate.

---

<div class="post-metadata">

**Author:** ![David\_Gabler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david_gabler/32/44332_2.png) [@David\_Gabler](https://community.glideapps.com/u/David_Gabler)\
**Post date:** [December 4, 2021, 3:06am UTC](https://community.glideapps.com/t/determine-if-row-exists-in-a-table/35491/7 "2021-12-04T03:06:26Z")

</div>

Well, and for reasons I cannot understand, because I made no changes at all, now the relation _is_ showing the Row ID. So, in essence, the relation really needs to be (Row ID + Email) in order to prevent duplicates. But I don’t see that it’s possible to make that relation, and if I could, it does not seem possible to interrogate the contents of the relation – only “is empty” and “is not empty”. So hopefully someone has another way to do this…

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/6/5/65e073b0d2577f9686ba04cf0f9f3daa92d6eb01.png)

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [December 4, 2021, 3:07am UTC](https://community.glideapps.com/t/determine-if-row-exists-in-a-table/35491/8 "2021-12-04T03:07:24Z")

</div>

> [@David\_Gabler](#):
>
> So, in essence, the relation really needs to be (Row ID + Email) in order to prevent duplicates.

Exactly. See my previous reply.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [December 4, 2021, 4:04am UTC](https://community.glideapps.com/t/determine-if-row-exists-in-a-table/35491/9 "2021-12-04T04:04:24Z")

</div>

> [@David\_Gabler](#):
>
> it does not seem possible to interrogate the contents of the relation

The relation just establishes a link between two datasets. To access data via the relation, there are other column types available - Lookup, Joined List, etc.

So for example, you could create a Joined List column through that relation to get a list of all email addresses. Then you could use that with “is included in”. But that would be quite convoluted and completely un-necessary in this case, because…

> [@Darren\_Murphy](#):
>
> what you need to do is create a template column in your Intentions table that joins the intention ID and user email address columns. Then build a similar template column using the selected intention ID and signed in users email address. Then use those two columns to build your relation. If it’s not empty, then you have a potential duplicate.

---

<div class="post-metadata">

**Author:** ![David\_Gabler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david_gabler/32/44332_2.png) [@David\_Gabler](https://community.glideapps.com/u/David_Gabler)\
**Post date:** [December 4, 2021, 4:40am UTC](https://community.glideapps.com/t/determine-if-row-exists-in-a-table/35491/10 "2021-12-04T04:40:56Z")

</div>

Thank you. This solution worked perfectly (create template column in main and sub table and a relation column in the main table). I used the is empty to display the add row button or not. I now have several columns I didn’t think I’d need. And I’ll probably go back one day and wonder what they’re for. But hopefully, I won’t delete them.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [December 4, 2021, 5:03am UTC](https://community.glideapps.com/t/determine-if-row-exists-in-a-table/35491/11 "2021-12-04T05:03:42Z")

</div>

> [@David\_Gabler](#):
>
> And I’ll probably go back one day and wonder what they’re for. But hopefully, I won’t delete them.

Glide Best Practice #42: _Never_ delete a column before first doing a [Find All Uses](https://docs.glideapps.com/all/reference/data-editor/managing-columns#find-all-uses) 😉

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [December 5, 2021, 5:04am UTC](https://community.glideapps.com/t/determine-if-row-exists-in-a-table/35491/12 "2021-12-05T05:04:15Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
