SELECT inner Join Group by sub query extract in a single row

Somasundaram M :

Here is my Query

SELECT * FROM pendingtreatment 
   INNER JOIN tbl_finds_d 
   ON tbl_appointments 
   ON pendingtreatment.pid = tbl_finds_d.pid

Pendingtreatment table

id  treatment    pid
 1  Rehabilation  5
 2  Extraction    5

tbl_appointments table

id  appointment  pid
 1  18-03-2020    5

tbl_finds_d table

id  finds      pid
 1  Allergy     5
 2  Sugar       5
 3  BP          5
hoangnh :

Presuming that you want to join three tables to get the desired data on foreign key pid

then sql should look like below :

SELECT pdt.treatment, aps.appointments, fd.finds
FROM pendingtreatment as pdt
INNER JOIN tbl_finds_d as fd
   ON pendingtreatment.pid = tbl_finds_d.pid
JOIN tbl_appointments as aps
   ON pendingtreatment.pid = tbl_appointments.pid

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=297847&siteId=1