至於結果說:
我想從tbl_appointment選擇所有數據,其中USER_ID = 100,
從tbl_doctor,
加
加入doctor_name我想加入第三張表tbl_document
凡
total_type1是計數(DOCUMENT_TYPE)其中DOCUMENT_TYPE = 1每個USER_ID和doctor_id對
total_type2是計數(DOCUMENT_TYPE)其中DOCUMENT_TYPE = 2每個USER_ID和doctor_id對
total_type3是count(document_type)其中document_type = 3每個USER_ID和doctor_id對
我想:
SELECT * FROM tbl_appointment AS main
JOIN(
SELECT doctor_id AS d_id,doctor_name FROM tbl_doctor
)doctor
ON man.doctor_id=doctor.d_id
where user_id=100
我很困惑加入我的第三個表,請大家幫我