Check a Value Exists in the Database

Hi Bubble Forum,

New user here, learning the basics. I’m creating a form in my application that has an input field and a button.

What I’d like to do is check whether the text value in the input field exists in a database. And if not show a pop-up.

I’ve been writing expressions and I keep stumbling on getting the binary Yes / No criteria to check if the value in my text field is in my database. Any help writing this expression is appreciated.

You just need to do a search for, and then use :count

If the count > 0 then the database already has an entry with the text value.

If the count is 0 then it doesn’t

1 Like

Thanks @adamhholmes

Basic follow-up question … how do I set that input field text as the value I’m checking against.

I have the action happening on the Button click, so I’m hitting wall passing the text input value as the value to check.

The expression I wrote in the screenshot will just check that my database table isn’t empty and has entries, correct? Not that my input field value is in the table though.

Click on Search for Customer Emails and add a constraint to the search where a field in the data type equals the text input’s value.

1 Like

Thank you @mikeloc - Thanks what I was missing!

Constraints are my new lesson for the day. :grin:

Appreciate you and @adamhholmes replying so fast.