SQL Database Connector Repeating Groups

I successfully connected to an external MySQL database using the SQL Database Connector. The table contains customer order data, most customers have multiple items but for each item the customer name, surname, phone, email etc is repeated.

Basic example of the data:
DB_Example

I am trying to achieve the following:
Have 2 Repeating groups, the first Repeating Group only list a unique list of customers, the second repeating group list the Items bought by the customer. When the user click on the Customer name (or an icon) in the 1st repeating group the customer’s items are listed in the 2nd Repeating group.

Thus far I’ve created two SQL Database Connector Queries, one listing all the customers and the other all the items and I managed to create the repeating groups. I am struggling make it work like I described above.

I am too inexperienced in Bubble to even know if I am on the right track? I am right creating the two separate queries, or can this be done with a singe query?

Any help would be much appreciated.

You can do this, and probably should, in one query. Although, that is a bit dependent upon how your app works and you’ll have to decide that based on various performance factors.
However, because this data does not appear to be normalized you can simply query the data just as you have above and then use the bubble “group by” mechanism to group the outer repeating group.

The solution is to create two repeating groups the first to display the customer and the second inside the first to loop over the items bought.

1 Like