Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MySQL上的案例比较不匹配_Mysql_Sql_Select_Compare_Case - Fatal编程技术网

MySQL上的案例比较不匹配

MySQL上的案例比较不匹配,mysql,sql,select,compare,case,Mysql,Sql,Select,Compare,Case,我尝试比较子查询结果的变量@ecart 我试图将变量转换成十进制,但这并没有改变什么 SET @ecart := 0; SELECT CASE @ecart := (TIME_TO_SEC(t.temps) - TIME_TO_SEC(( SELECT MIN(t.temps) as Temps FROM temps t INNER JOIN inscr

我尝试比较子查询结果的变量@ecart

我试图将变量转换成十进制,但这并没有改变什么

SET @ecart := 0;
SELECT CASE @ecart := (TIME_TO_SEC(t.temps) - TIME_TO_SEC((
                        SELECT MIN(t.temps) as Temps
                        FROM temps t
                        INNER JOIN inscription i ON t.ide_inscription = i.id AND i.ide_calendrier = 3
                        INNER JOIN type_temps tt ON tt.id = t.ide_type_temps AND tt.intitule = 'Temps Final')))
    WHEN @ecart = 0 THEN ""
    WHEN @ecart<60 THEN CONCAT('+',@ecart)
    WHEN @ecart BETWEEN 60 AND 3600 THEN CONCAT('+',SEC_TO_TIME(@ecart))
    ELSE CONCAT('++',@ecart)
    END as Ecart
FROM dag_evenement.temps t
INNER JOIN dag_evenement.inscription i ON t.ide_inscription = i.id AND i.ide_calendrier = 3
INNER JOIN dag_evenement.type_temps tt ON tt.id = t.ide_type_temps AND tt.intitule = 'Temps Final'
INNER JOIN dag_ticketing2.personne p ON i.ide_personne = p.IDPersonne
ORDER BY t.temps ASC;

谢谢你的帮助

结果应该是?我想显示如果@ecart=0,则不显示减号;如果ecart<60,则显示ecart如果ecart>=60,且ecart<3600,则显示分:秒;如果ecart<3600,则显示时间,格式为H:I:s,但当我尝试只测试第一个,否则不匹配第二个和第三个
+0
++15
++58
++125
++141
++157
++209
++226
++240
++271
++283
++288
++290
++296
++298