How to search a database - is it so hard for this MBA?

I want to be able to search a database of records which have e.g unique fruits and their color as fields. The user searches for the fruit (please ignore upper/lower case or repeated fruits etc.) and if it’s in the database I want to output the color of that fruit. If the fruit isn’t found, then output some alert e.g. “not found”.

I asked this previously but got answers that had repeating groups and hidden fields for converting to uppercase etc. At first this got me excited but it has thrown me off totally.

I just want to see it working this simple way. Can someone point me to an example of this so I can learn how to do it myself? I went through the tuorials and the (very old MVP) videos in the learning center but there’s nothing about searching.

Please confirm an MBA can do this and I don’t need to go back to programming :wink:


Confirmed. Your repeating group displays the results of your search. You can build a search the the same fashion (select, merge, intersect) as you would with code. You can also display text dynamically using conditions in the element editor.

Hi Scott - So I have to use a repeating group for a search that either has 1 hit or none? I don’t want the scroll bar showing for the results…

Let me see if I got your use case correct here:

User searches for “apple”
If “apple” exists in the database, your app displays one result: “red”
If “apple” does not exist, your app displays something like: “No results”

Is that what you’re asking for?

Yes - that’s what I want. I know it probably sounds like a dumb question but videos and examples on how to search the database are hard to come by.

Interestingly enough, this is a strange use case. Usually, when people are searching for something, they’re expecting lists of things back.

I don’t know your specific use case, but in the fruit example, I think it makes more sense to use a dropdown to select the fruit type, rather than a search box. I’ll build a quick example, though, to show how it can be done. Gimme just a few minutes!

I can’t list the fruits as I don’t want to show all the fruits in the database. It’s a privacy issue wrt my actual application. So people are checking if a fruit is in my database but if it isn’t I don’t want them to know which ones are in there.

The top uses the dropdown (which you just explained isn’t suitable for your use case)

The bottom uses a text input. The text to the right of the input is looking for an exact match for a fruit’s name, to show the fruit’s color. Let me know if you have any questions about the setup.

1 Like

Ahh ok got it. Looks simple and this is what I needed. I gather the bottom "output’ element is a text element? Sometimes it’s hard to see what these are but when I click the “i” for information the video is saying it’s a text element.

Thank you so much!

Yep! It’s just a text element. If ya have any other questions on this, lemme know!

One more question - if someone types in say Apple or apple and I want either one or any other case to match how do I add that step, using the bottom search style you gave in the example?

That is what the Hidden Input is for I am afraid.

If you make both the database field and the input upper case (the input via a hidden input) then it will ignore case.

People say you can do it via setting the Initial Value (example 2) but I can’t make that work.

it is clunky, so if there is another way…

I thought I had a quick answer to this, but anytime I seem to know something that you don’t, I get the belief I’m doing something wrong :slight_smile:

I added a new section called "By Input (Ignore case Andrew). In this example, the text that’s showing the fruit color is doing a search for fruit, where name=input E’s value:lowercase, then showing the first item that gets returned. That appears to be working as I expect it. I’m not using any hidden inputs or initial value tricks here, which makes me wonder what it is I’m forgetting.

1 Like

I am probably overthinking it, but it does depend on the case of the database field.

If you can guarantee it is all lower case in the field then that is much much easier.


However, if you have “Orange” then it doesn’t work. I think it was searching for Surnames that prompted this. Yes you can save a lowercase version each time, but that is a bit of a pain too.

For whatever reason you can say name:lowercase = input:lowercase (or the other way round) in Bubble.

1 Like

Yeah, you’re totally right about that. Good point!

Thanks guys this really helped me. I was getting bogged down in complicated search queries. The last example was great because I am storing my data in lowercase so I don’t need to do the “double” conversion - just on the input.

I really appreciate you taking the time to help me burst my first bubble layer :slight_smile:

No problemo. If other people wouldn’t have done the same for me when I joined back in 2015, I’d have given up mega fast. Bubble’s not perfect, but it’s trying to push in a direction I believe in.