我有这个 SQL 查询,它完美地工作,我现在的问题是我不能echo它,因为它被用于LEFT()
这是整个代码。
$empid='D001'
$sql = "Select
DISTINCT TOP 1
LEFT (employeeidno, 4) as deptcode,
RIGHT(employeeidno, 7) as empno
FROM employeemasterfile
WHERE
LEFT (employeeidno, 4)='D001'
ORDER BY
RIGHT(employeeidno, 7) DESC";
include 'query/sqlsrv_query-global.php';
if(sqlsrv_num_rows($query) > 0) {
while($row = sqlsrv_fetch_array($query, SQLSRV_FETCH_ASSOC)) {
$accountcode=$row['deptcode'] + 1;
echo "<option value='".$row['deptcode'].":".$accountcode."'>".$row['deptcode']."</option>";
}
}
有没有办法来解决这个问题?我尝试使用AS,不幸的是没有运气。
HUX布斯