• Календарь в БД Mysql?

    Rsa97
    @Rsa97
    Для правильного вопроса надо знать половину ответа
    Можно.
    Например, так:
    SELECT '2017-01-01' + INTERVAL `d`.`dayOfYear` DAY + INTERVAL `h`.`hour` HOUR
      FROM (
        SELECT (`c`.`num`*100+`d`.`num`*10+`s`.`num`) AS `dayOfYear`
          FROM (
            SELECT 0 AS `num`
            UNION SELECT 1
            UNION SELECT 2
            UNION SELECT 3
            UNION SELECT 4
            UNION SELECT 5
            UNION SELECT 6
            UNION SELECT 7
            UNION SELECT 8
            UNION SELECT 9
    	  ) AS `s`
    	  JOIN (
    	    SELECT 0 AS `num`
            UNION SELECT 1
            UNION SELECT 2
            UNION SELECT 3
            UNION SELECT 4
            UNION SELECT 5
            UNION SELECT 6
            UNION SELECT 7
            UNION SELECT 8
            UNION SELECT 9
          ) AS `d` ON TRUE
          JOIN (
            SELECT 0 AS `num`
            UNION SELECT 1
            UNION SELECT 2
            UNION SELECT 3
            UNION SELECT 4
            UNION SELECT 5
            UNION SELECT 6
            UNION SELECT 7
            UNION SELECT 8
            UNION SELECT 9
          ) AS `c` ON TRUE
          HAVING `dayOfYear` < DAYOFYEAR('2017-12-31') 
      ) AS `d`
      JOIN (
        SELECT 0 AS `hour`
        UNION SELECT 1
        UNION SELECT 2
        UNION SELECT 3
        UNION SELECT 4
        UNION SELECT 5
        UNION SELECT 6
        UNION SELECT 7
        UNION SELECT 8
        UNION SELECT 9
        UNION SELECT 10
        UNION SELECT 11
        UNION SELECT 12
        UNION SELECT 13
        UNION SELECT 14
        UNION SELECT 15
        UNION SELECT 16
        UNION SELECT 17
        UNION SELECT 18
        UNION SELECT 19
        UNION SELECT 20
        UNION SELECT 21
        UNION SELECT 22
        UNION SELECT 23
      ) AS `h` ON TRUE
    Ответ написан
    2 комментария
  • Подключение из идеи к БД?

    zolt85
    @zolt85
    Программист
    Ответ написан
    Комментировать