I want to select the headers (and ID-s) from a table grouped by date, but like below.
The cell on the left is ID
The cell on the right is Title
The middle cell is Date
Select ID
, Title
, Date
BY from the
News group in order of
Date Date
DESC;
To display grouping by value as a header in MySQL, you can use the
GROUP_CONCAT
function in conjunction with theCONCAT
function to concatenate the grouped values with a string. Here is an example query:In this query, replace
group_column
with the name of the column you want to group by, and your_table with the name of the table.CONCAT
Function combines the string "Group:" with the value of group_column to create a header. TheCOUNT
function counts the number of rows in each group.This will generate a result set with two columns: the title column and the count column. The title column will display the group value concatenated with the string "Group:".