By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE tbl_user_details(
id int, name varchar (25));
insert into tbl_user_details values
(1,'User 1');
CREATE TABLE tbl_pressure (
id int, pressure varchar(10));
insert into tbl_pressure values
(1,'120/80'),
(1,'130/90'),
(1,'140/95');
CREATE TABLE tbl_therapy(
id int,therapy varchar(10));
insert into tbl_therapy values
(1,'drug A'),
(1,'drug B'),
(1,'drug C'),
(1,'drug D');
SELECT t1.id,
max(t1.name),
group_concat(distinct
t3.pressure
SEPARATOR '\n')
pressures,
group_concat(distinct
t4.therapy
SEPARATOR '\n')
therapies
FROM tbl_user_details as t1
LEFT JOIN tbl_pressure as t3
ON (t1.id=t3.id)
LEFT JOIN tbl_therapy as t4
ON (t1.id=t4.id)
GROUP BY
t1.id
id | max(t1.name) | pressures | therapies |
---|---|---|---|
1 | User 1 | 120/80 130/90 140/95 |
drug A drug B drug C drug D |