Select rows grouped by date
P粉729436537
P粉729436537 2023-09-12 13:45:48
0
1
626

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;

P粉729436537
P粉729436537

reply all(1)
P粉738046172

To display grouping by value as a header in MySQL, you can use the GROUP_CONCAT function in conjunction with the CONCAT function to concatenate the grouped values ​​with a string. Here is an example query:

SELECT CONCAT('Group:', group_column) AS header, COUNT(*) AS count
FROM your_table
GROUP BY group_column;

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. The COUNT 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:".

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template