Get multiple categories and show as for example "badge"?

Congrats to Wappler 1.7.2 and Server Side API! Lets say I have two tables:

@Hyperbytes Maybe you as DB freak know that or @Teodor
Short Example:
What is what:
t_ = table
f_ = foreinkey

DB Structure Example:
t_article (artid, artname)
t_cat_art_depencies (catartid,f_artid, fcatid)
t_category

Now i have articles like: banana which is category fruit and vegan, then i have an article “T Bone Steak” which is category meat.

SO now how to list the categories within a table query which should give a result like:

ID Article Category
1 Banana Fruit, Vegan
2 Steak Meat
3 Cellerie Vegetables, Vegan

Bonus Question:
As I guess the output would be like:
Var, Var, Var,
and how to strip the last comma then? :smiley:

Hello my friend
@Freddy_Blockchain ,

if you want to do this on server side ;

{{(query1[0].values(‘urun_rez_kat’))[0].split(",")}}

you could use "group by " for your example

@s.alpaslan okay but I still dont get it. Your query shows that „subquery“ for my categories? I mean do I need two queries on Server Connect?

One with the articles
The second which loops trough the articles?

Maybe screenshot of the Server Connect would help…

Hello @Freddy_Blockchain
Yeap you need 2 queries

1 ) list your category names via repater
2) create second query then use where condtion inside the query (where = categorie name)
3) set variable and populate all query2 results in new variable … use this {{(query1[0].values(‘urun_rez_kat’))[0].split(",")}}

1 Like

i‘ll try that tomorrow! Just wasn‘t sure how to pass a variable :grinning:

@Freddy_Blockchain

if you want to use group by create like ;

Results :slight_smile:

3 Likes

Ok I’m trying your solution, but the set variable isnt clear for me. You pass that value from query 1 ? Do i need to have a “group by” in Query1 ? How looks query one is my question… :-:roll_eyes:

I can see that you have: SET VALUE AS. But is “AS” in your case the Name of your variable? Like my example here with questionmarks:

I cannot really use wappler to define my actions, as my DATA looks empty. But of course I got data and it works. But I cannot select any fields from the expression builder. It just shows nothing to select as property :

yeap AS is test name for me … you can use different name for variable but dont forget you will be use it in other query .

repeat expression will be as.keys() or xxxx.keys() this will return your grouped items like my DOGU,BATI,KUZEY,GUNEY

Then you will use this keys in second query’s WHERE clouse

property field name will be your field name for grouping

Ok thanks for that! I‘m just wondering why I cannot use the expression builder. I just do that now blindly and try to get it working. I think not the way how to use wappler. As I cannot get results from expression builder when using GROUP function or any other function…???

try this field name
t_category

@s.alpaslan ok still trying to get it working. With your solution I need to change complete Server Connect logic, which is complex already. As I’m filtering them and getting back two different queries. Both Queries then need to be changed with your steps. Also I would need to change my App Connect side where I use a filter and would need to change all Databindings, cause I need to change the root data path. Not sure if you know what I mean?

So now I have that here, but I dont use the server connect as data binding, as I have a filter. So how does your app connect look like? That would help, as my query is still not working.

I guess it would be easier to make two different Server Actions?

  1. Mainquery and create a Server Connect
  2. Add that Subquery with Categories as Sub Server Connect and then filtered by first mainquery.

This post is solved with that how to here