从查询结果中减去1

时间:2011-04-29 01:23:54

标签: mysql

SELECT count(P.pID)
FROM Department D, Professor P
WHERE D.dID = ? AND P.dID = D.dID;

我想从count(P.pID)的任何结果中减去“1”。因此,例如,如果P.pID的值为10,则输出9 ...... ??

3 个答案:

答案 0 :(得分:4)

SELECT count(P.pID) - 1 as pID_count 
FROM Department D, Professor P 
WHERE D.dID = ? AND P.dID = D.dID;

答案 1 :(得分:2)

怎么样?
SELECT count(P.pID) - 1
FROM Department D, Professor P
WHERE D.dID = ? AND P.dID = D.dID;

答案 2 :(得分:1)

SELECT count(P.pID)-1
FROM Department D, Professor P
WHERE D.dID = ? AND P.dID = D.dID;