У меня следующий запрос:
SELECT IF(IF(atmp = 1 AND h_start1 <= (SELECT HOUR(NOW())) AND
(SELECT HOUR(NOW())) <= h_stop1 OR
h_start2 <= (SELECT HOUR(NOW())) AND
(SELECT HOUR(NOW())) <= h_stop2,
t_temp1,
set_temp) < temp - modEn AND ccl = 1,
1,
0) clima,
IF(IF(atmp = 1 AND h_start1 <= (SELECT HOUR(NOW())) AND
(SELECT HOUR(NOW())) <= h_stop1 OR
h_start2 <= (SELECT HOUR(NOW())) AND
(SELECT HOUR(NOW())) <= h_stop2,
t_temp1,
set_temp) > temp + modEn AND cct = 1,
1,
0) centrala,
'studio' camera
FROM (SELECT (SELECT date
FROM termostat
WHERE topic = 'control-clima'
AND incapere = 'studio'
AND zi = 'miercuri') ccl,
(SELECT date
FROM termostat
WHERE topic = 'control-centrala'
AND incapere = 'studio'
AND zi = 'miercuri') cct,
(SELECT date
FROM termostat
WHERE topic = 'auto-temp'
AND incapere = 'studio'
AND zi = 'miercuri') atmp,
(SELECT date
FROM termostat
WHERE topic = 'mod'
AND incapere = 'studio'
AND zi = 'miercuri') modEn,
(SELECT date
FROM termostat
WHERE topic = 't-temp1'
AND incapere = 'studio'
AND zi = 'miercuri') t_temp1,
(SELECT date
FROM termostat
WHERE topic = 't-temp2'
AND incapere = 'studio'
AND zi = 'miercuri') t_temp2,
(SELECT date
FROM termostat
WHERE topic = 'h-start1'
AND incapere = 'studio'
AND zi = 'miercuri') h_start1,
(SELECT date
FROM termostat
WHERE topic = 'h-start2'
AND incapere = 'studio'
AND zi = 'miercuri') h_start2,
(SELECT date
FROM termostat
WHERE topic = 'h-stop1'
AND incapere = 'studio'
AND zi = 'miercuri') h_stop1,
(SELECT date
FROM termostat
WHERE topic = 'h-stop2'
AND incapere = 'studio'
AND zi = 'miercuri') h_stop2,
(SELECT date
FROM termostat
WHERE topic = 'set-temp'
AND incapere = 'studio'
AND zi = 'miercuri') set_temp,
(SELECT date
FROM termostat
WHERE topic = 'studio/climat/temperatura') temp) t1
Все идет хорошо, но без студийного микросхемы комнаты, у меня проблема Subquery returns more than 1 row
С тем же кодом я могу читать данные о обогреве и кондиционере в специально выделенной комнатеи день из остальных комнат ...
Может быть, некоторые из вас также помогут мне улучшить запрос (я знаю, что места гораздо лучше!)
Спасиборебята!