If I understand you correctly you should be able to use a union between the tables.
SELECT 'table1' AS soure', title , description FROM table1
UNION ALL
SEELCT 'table2' AS source, title, description FROM table2
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I need to grab a query from different tables which have different number of columns to display and different column names. I like to out put into a Table format. Listed below is a sample query which has Title and Description as column name. The number of columns can vary. Since the column name (title and description) can be different for different queries, what is the best approach to display the data in a table format
Datasource:
array:2 [▼
0 => array:2 [▼
"title" => "TITLE1"
"description" => "DESCRIPTION1"
]
1 => array:2 [▼
"title" => "TITLE 2"
"description" => "NEW DESCRIPTION"
]
Output into Table format:
title | description
___________________________
TITLE1 | DESCRIPTION1
TITLE2| NEW DESCRIPTION
@johnw65 I think you need to create some kind of helper function that converts the collection into columns and rows. Another option is to take a look at datatables.
Please or to participate in this conversation.