Combining two different table queries into one output for use in a repeat

Hey all,

I’ve not kept up to date each week with updates and I see there has been a fair amount of updates to queries, and the database manager.

Is there now a possibility to combine two DB Queries into a single output that’s useable in a repeat? If there is (awesome) what would be the best approach, or link to documentation I can study?

1 Like

Thanks @Sorry_Duh - I thought of the join function, but unfortunately there isn’t a ‘matching’ id number between the collections we wish to join, while the info is fairly similar, the items are not aligned in anyway so I was wondering if another feature has been developed that could solve that.

So following what logic they should be joined? Can you share sample output from the two queries and the result you need?

Hey Teo,

So what we have is a transaction history for a single web3 wallet address.

Their transaction history is stored in two different tables. The items they are buying, are entirely different from each other so there is no common id, or common link between the two.

I want to output the transaction history of both tables into one output I can then show on the F/E.

Example:

TXN Table 1:

id
item_name
description
price
txn
item_id (linking to that specific purchases table)

TXN Table 2
id
collection_name
description
price
txn
item_id (linking to that specific purchases table)

the item_id is not a common link between the two, as they themselves are separate tables with unique information.

So the goal here would be to have a single output:

id
name (which would be either item_name or collection_name)
description
price
item_type (e.g. type one, or type two)
date etc.

Ok but then how do you know which record from table 1 should be joined with which in table 2?
Or do you just want to list all records from table 1 followed by all records from table 2 in a single output?

Correct - they aren’t joined by anything, I would just like to be able to show records from both tables in a single output

What database are you using?

MariaDB

You can use sql UNION for this https://www.w3schools.com/sql/sql_union.asp
So setup a custom database query in your server action and use it there.
Example:

SELECT id, item_name AS name, description, price, txn, item_id FROM Table1
UNION
SELECT id, collection_name AS name, description, price, txn, item_id FROM Table2
1 Like

ty Teo - i’ll try this out. Much appreciated!

this worked great, thanks Teo. Perhaps a Union visual implementation in Wappler would be cool in the future!

1 Like

Hi,
How did you proceed?
I have exactly the same need.
Many thanks

Please check the reply marked as a solution.

That’s already possible using the Server Connect Array List component:

This topic was automatically closed after 2 days. New replies are no longer allowed.