localhost mysql查询结果与linux mysql查询结果有区别

时间:2014-12-31 07:50:43

标签: php mysql

我的数据库中有8个表,我需要在一个查询中包含所有必需的数据。 当我在localhost上运行mysql中的查询返回true结果(12行)但是当我在linux服务器上运行mysql时返回最后一行......

我的查询是:

SELECT `mhr_patients`.`id`, 
`mhr_patients`.`fullName`, 
`mhr_patients`.`nationalCode`, 
`mhr_patients`.`age`, 
`mhr_patients`.`firstGCS`, 
`mhr_patients`.`fileNumber`, 
`mhr_patients`.`isUnKnown`, 
`mhr_patients`.`docDetail`, 
`mhr_patients`.`presentation`, 
`mhr_patients`.`appRegisterTime`, 
`mhr_patients`.`inspectorRegisterTime`, 
`mhr_patients`.`patientStatusDetail`, 
`mhr_patients`.`patientDetail`, 
`mhr_patients`.`status`, 
`docT`.`text` AS docText, 
`tolOp`.`name` AS tolOpName, 
`tolOp`.`color` AS tolOpColor, 
`tolOp`.`res1` AS tolOpTextColor, 
`pLog`.`breathing`, 
`pLog`.`bodyMovement`, 
`pLog`.`faceMovement`, 
`pLog`.`gag`, 
`pLog`.`cough`, 
`pLog`.`cornea`, 
`pLog`.`pupil`, 
`pLog`.`dollEye`, 
`pLog`.`secondGCS`, 
`pLog`.`sedation`, 
`pLog`.`inspector`, 
`pLog`.`status` As pLogStatus, 
`pLog`.`section`, 
`pLog`.`id` AS pLogId, 
`pLog`.`typeOfSection`, 
`pLog`.`lastUpdateTime`, 
`pLog`.`isTransfer`, 
`pLog`.`opu`, 
`hos`.`name` AS hosName, 
`mhr_opu`.`name` AS opuName, 
`mhr_opu`.`id` AS opuId, 
`mhr_states`.`name` AS cityName, 
`mhr_inspectors`.`name` AS insName 
FROM (`mhr_patients`) 
JOIN `mhr_doc` AS docT ON `docT`.`id` = `mhr_patients`.`doc` 
JOIN `mhr_tol_options` AS tolOp ON `tolOp`.`id` = `mhr_patients`.`patientStatus` 
JOIN `mhr_patients_log` AS pLog ON `pLog`.`pId` = `mhr_patients`.`id` AND pLog.id = (SELECT MAX(mhr_patients_log.id) FROM mhr_patients_log WHERE mhr_patients_log.pId = mhr_patients.id) 
JOIN `mhr_hospitals` AS hos ON `hos`.`id` = `pLog`.`hospital` 
JOIN `mhr_opu` ON `mhr_opu`.`id` = `pLog`.`opu` 
JOIN `mhr_states` ON `mhr_states`.`id` = `pLog`.`city` 
JOIN `mhr_inspectors` ON `mhr_inspectors`.`id` = `pLog`.`inspector` 
WHERE 
`mhr_patients`.`status` =  5 
GROUP BY `pLog`.`pId` 
ORDER BY `mhr_patients`.`inspectorRegisterTime` asc 
LIMIT 30

问题是什么?

1 个答案:

答案 0 :(得分:0)

我改变了

JOIN `mhr_inspectors` ON `mhr_inspectors`.`id` = `pLog`.`inspector`

LEFT JOIN `mhr_inspectors` ON `mhr_inspectors`.`id` = `pLog`.`inspector`

我的问题解决了。 :)