我已经为连接三个表写了查询但是它出错了无法读取属性'长度'未定义的。
这是我的查询
var userquery = 'SELECT Device_Id,DATE_FORMAT(Date, "%d/%m/%Y") AS Date,Time,Session_Status,Associate_id,Patient_ID,Session_Id,Applicator_Type,Intensity,Motor_Frequency,CONCAT(PEMF_Min_Freq,"-",PEMF_Max_Freq)as PEMF,Waveform,Treatment_Duration, CONCAT(therapy_session_info.Patient_iid,"-",patient_info.first_name)as patient_info,patient_info.condition1, user_device_mapping.device_id from therapy_session_info INNER JOIN patient_info ON therapy_session_info.Patient_iid=patient_info.patient_id INNER JOIN user_device_mapping ON therapy_session_info.Device_Id=user_device_mapping.device_id where doctor_id=? and Date > DATE_SUB(NOW(), INTERVAL 2 DAY) ';
one: function (callback) {
db.query('SELECT doctor_id from user_info where email_id=?', [name], function (error, rows, fields, next) {
for (var i in rows) {
console.log('----------hhh--111-' + rows[i].doctor_id);
}
db.query(userquery,[rows[i].doctor_id], function (error, rows, fields, next) {
console.log('length--' + rows.length);
callback(error, rows);
console.log('report fetching error---'+rows);
});
});
}
这是therapy_session_info表
| id | Device_Id | Date | Time | Session_Status | associate_id | Patient_iid | Session_Id | Applicator_Type | Intensity | Motor_Frequency | PEMF_Min_Freq | PEMF_Max_Freq | Waveform | Treatment_Duration |
+----+-----------+------------+----------+----------------+--------------+-------------+------------+-----------------+-----------+-----------------+---------------+---------------+----------+--------------------+
| 2 | 0001 | 2016-11-30 | 15:11:05 | C | 0001 | 0001 | 123 | M | 10 | 15 | 4 | 8 | 1 | 5 |
| 3 | 0003 | 2016-11-30 | 15:11:05 | C | 0002 | 0002 | 456 | P | 12 | 100 | 7 | 14 | 3 | 8 |
这是patient_info表
| id | patient_id | doctor_id | first_name | middle_name | last_name | age | gender | weight | condition1 | diagnose | pcontact_no | scontact_no | email_id | address | link | comment | status | creation_date | photo | modified |
+----+------------+-----------+------------+-------------+-----------+-----+--------+--------+------------------+------------------+-------------+-------------+-------------------------+---------+------+---------+--------+---------------------+------------------------------------------------------------------------------------------+---------------------+
| 1 | 0001 | 0054 | sunita | b | kadam | 26 | Female | 45 | Frozen shoulder | Select Diagnose | 9503709388 | | sunitakadam88@gmail.com | | | | 1 | 2016-11-25 14:35:28 | /home/smartleaven/PTD_NEW/UserPortal/uploads/images/8961a2ac13575fce548715410d006c3a.png | 2016-11-25 14:53:46 |
| 2 | 0002 | 0054 | nilam | m | mane | 26 | Female | 44 | Lower back pain | Select Diagnose | 9854646464 | NULL | nilammmm@yahoo.com | NULL | NULL | NULL | 1 | 2016-11-25 14:38:19 | NULL | 0000-00-00 00:00:00 |
这是user_device_mapping表
+----+----------------------+-----------+---------------------+
| id | doctor_id | device_id | creation_date |
+----+----------------------+-----------+---------------------+
| 2 | 0069 - rahul kadam | 0002 | 2016-11-28 17:11:14 |
| 4 | 0063 - Sunita Kadam | 0001 | 2016-11-28 17:42:35 |
| 5 | 0063 - Sunita Kadam | 0003 | 2016-11-28 17:50:21 |
+----+----------------------+-----------+---------------------+