I want to group fields but want to show all row of a column called remain
:
here is current output without grouping:
And output with group:
And I want This when I group:
Here is mysql query:
SELECT staff.name,
staff.designation_id_designation,
staff.status_id_status,
Concat_Ws('=', leave_remain.leave_type_id_leave_type, leave_remain.days) AS
remain
FROM staff INNER JOIN
leave_remain ON staff.id_staff = leave_remain.staff_id_staff
GROUP BY staff.name
use GROUP_CONCAT
SELECT staff.name,
staff.designation_id_designation,
staff.status_id_status,
GROUP_CONCAT(Concat_Ws('=', leave_remain.leave_type_id_leave_type, leave_remain.days)) AS remain
FROM staff
INNER JOIN leave_remain
ON staff.id_staff = leave_remain.staff_id_staff
GROUP BY staff.name, staff.designation_id_designation, staff.status_id_status
other Link(s)
Try this:
SELECT staff.name,
staff.designation_id_designation,
staff.status_id_status,
GROUP_CONCAT(Concat_Ws('=', leave_remain.leave_type_id_leave_type, leave_remain.days) SEPARATOR ' ') AS remain
FROM staff INNER JOIN
leave_remain ON staff.id_staff = leave_remain.staff_id_staff
GROUP BY staff.designation_id_designation,
staff.name,
staff.status_id_status;
TRy this for this we need to use group_contact seperate by ' '.
SELECT staff.name,
staff.designation_id_designation,
staff.status_id_status,
GROUP_CONCAT(Concat_Ws('=', leave_remain.leave_type_id_leave_type, leave_remain.days) SEPARATOR ' ') AS remain
FROM staff
INNER JOIN
leave_remain
ON
staff.id_staff = leave_remain.staff_id_staff
GROUP BY staff.designation_id_designation,
staff.name,
staff.status_id_status;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With