Getting non-unique values

Hello everyone

There is a table with the “tags” field. What is the easiest way to get a tag or tags that are contained in all table entries?

Example: if there are two records in the table. The first contains tags: tag1, tag2, tag3 in the second: tag2 Then the query should return the value: tag2

Thank you in advance!

It’s very funny. I was able to build very complex queries to the database. But now I’m confused. It seems that the task is very simple - filter only those values that are in all the records of the table. However, when I try to implement it, I get stuck.

I will be grateful for any ideas for implementation.

Here are a couple of examples to better explain the task I’m trying to solve.

Example 1

Table is given:

Answer (which tags are non-unique): 0


Example 2

Table is given:

Answer (which tags are non-unique): tag2, tag3


Any ideas on how to implement this.

PS No one has any ideas? @Hyperbytes I may be wrong, but I think I’ve seen something similar in one of the many examples of tasks you’ve given in this forum. But I can’t find this topic. Did you describe something similar?

You can just use the custom query for this… So something like:

SELECT id, tags, COUNT(tags) 
FROM your_table_name_here
GROUP BY tags
HAVING COUNT(tags) > 1

This will return all the tags which are stored more than once in your table.

Unfortunately, this custom query performs a different function - it returns tags assigned to records more than once. My task is different.

I will describe it in more detail for a better understanding. I use a relational many-to-many relationship between products and tags:

The user can select multiple products in the table. The IDs of the selected products fall into an array that is used as a filter.

Now the task:

I need to find out what tags are associated with each of the selected products. Thus, if the user selected product1, product2, and product3, which are associated with multiple tags, but only one tag is shared, I will get this tag as a response. If the user chose say product4, product5, product6, and product4 are not linked to tags at all, then I should get back the answer 0, even if product5 and product6 have common tags.

I hope Google translated not too distorted and the General meaning is clear. If something is unclear, I will explain it differently.

Thank you in advance for your help.

I feel that Wappler can provide a very simple and effective solution to my task, perhaps even without using a custom query, but using a combination of several simple queries. However, I haven’t been able to find the right solution for two days. Guys, I will be very grateful for any help or idea on how to implement the above task in Wappler.