我把一个查询放在一起收集来自几个不同表的数据,这在SQL server studio中运行正常但是当我尝试使用ODBC连接在PHP中运行查询时,我得到以下错误
Warning: odbc_exec(): SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]Conversion failed when converting the varchar value 'Default' to data type int., SQL state 22005 in SQLExecDirect in C:\xampp\htdocs\T_A\People.php on line 40
Error in SQL
以下是查询
SELECT ATDSchedulingRule.Name, ATDSchedulingRule.Remark, ATDShiftDetail.WorkHour, RIGHT(ATDShiftDetail.StartTime, 6) AS StartTime,
RIGHT(ATDShiftDetail.EndTime, 6) AS EndTime, RIGHT(CHINA_VISION_PubPersonnel.ID, 4) AS ClockNo, CHINA_VISION_PubCards.CardCode
FROM ATDShiftDetail INNER JOIN
ATDSchedulingRule ON ATDShiftDetail.ATDShift_Ref = ATDSchedulingRule.Shift_Ref2 INNER JOIN
CHINA_VISION_PubCards INNER JOIN
CHINA_VISION_PubPersonnel ON CHINA_VISION_PubCards.PubPersonnel_Ref = CHINA_VISION_PubPersonnel.Reference ON
ATDSchedulingRule.Name = RIGHT(CHINA_VISION_PubPersonnel.ID, 4)
WHERE (ATDShiftDetail.WorkHour > 0) AND (CHINA_VISION_PubPersonnel.Telephone > '1') AND (ATDSchedulingRule.Name = '1877')
这是PHP
Public function GetPersonData() {
$conn = odbc_connect('easydo', '', '');
if (!$conn) {
exit("Connection Failed: " . $conn);
}
$sql = "SELECT ATDSchedulingRule.Name, ATDSchedulingRule.Remark, ATDShiftDetail.WorkHour, RIGHT(ATDShiftDetail.StartTime, 6) AS StartTime,
RIGHT(ATDShiftDetail.EndTime, 6) AS EndTime, RIGHT(CHINA_VISION_PubPersonnel.ID, 4) AS ClockNo, CHINA_VISION_PubCards.CardCode
FROM ATDShiftDetail INNER JOIN
ATDSchedulingRule ON ATDShiftDetail.ATDShift_Ref = ATDSchedulingRule.Shift_Ref2 INNER JOIN
CHINA_VISION_PubCards INNER JOIN
CHINA_VISION_PubPersonnel ON CHINA_VISION_PubCards.PubPersonnel_Ref = CHINA_VISION_PubPersonnel.Reference ON
ATDSchedulingRule.Name = RIGHT(CHINA_VISION_PubPersonnel.ID, 4)
WHERE (ATDShiftDetail.WorkHour > 0) AND (CHINA_VISION_PubPersonnel.Telephone > '1') AND (ATDSchedulingRule.Name = $this->Op )
";
$rs = odbc_exec($conn, $sql);
if (!$rs) {
exit("Error in SQL");
}
var_dump($rs);
}