0
select player.ActionTime from question_log log inner join player_question player 
where log.ActionType='96'

select player.ActionTime from question_log log inner join player_question player 
where log.ActionType='97'

如何在 mysql 语法中实现这一点?选择 ActionType 为 96 减去另一个为 97 的 Actiontime。算术减。

4

2 回答 2

3
SELECT t96.ActionTime - t97.ActionTime
FROM
(
    select player.ActionTime 
    from question_log log 
    inner join player_question player 
    where log.ActionType='96'
) t96
CROSS JOIN
(
    select player.ActionTime 
    from question_log log 
    inner join player_question player 
    where log.ActionType='97'
) t97

请注意,您的两个查询之间似乎没有任何关系,所以我只能建议一个CROSS JOIN(笛卡尔积)。如果你有不止一行 log.ActionType = '96' 或 log.ActionType = '97' 你将有很多结果行。

于 2013-01-25T08:25:05.527 回答
0

使用子查询:

SELECT player.ActionTime - (SELECT player.ActionTime from question_log log inner join     player_question player where log.ActionType='97' LIMIT 1)
from question_log log inner join player_question player where log.ActionType='96'
于 2013-01-25T08:26:27.293 回答