我尝试使用几个帮助表来显示计时器的状态。 (用php浏览器) 辅助表用于在语言之间切换。
这里是Timer Types的辅助表:
+-------------+------+------------------+
| lfdLanguage | Type | TText |
+-------------+------+------------------+
| 0 | 0 | Puls |
| 0 | 1 | steigende Flanke |
| 0 | 2 | fallende Flanke |
| 1 | 0 | Pulse |
| 1 | 1 | rissing edge |
| 1 | 2 | falling edge |
+-------------+------+------------------+
和Day Active:
+-------------+--------+--------+
| lfdLanguage | Active | ACText |
+-------------+--------+--------+
| 0 | 0 | _ |
| 0 | 1 | X |
| 1 | 0 | _ |
| 1 | 1 | X |
+-------------+--------+--------+
通常我使用equi连接,但在这里我想使用相同的帮助表来显示日期的状态(即RunMonday,...)。
在没有AND WHERE HTT.lfdLanguage = 0
的情况下使用以下语句可以正常工作。
但是我可以通过where声明来执行。我收到一个错误:
(' ERROR 1064(42000):.....')
SELECT DISTINCT
T.lfdTimer,
T.Active,
T.Name,
T.Type, HTT.TText,
T.RunMonday, HTDA1.ACText,
T.RunTuesday, HTDA2.ACText,
T.RunWednesady, HTDA3.ACText,
T.RunThursday, HTDA4.ACText,
T.RunFriday, HTDA5.ACText,
T.RunSaturday, HTDA6.ACText,
T.RunSunday, HTDA7.ACText
FROM
Timer T
INNER JOIN HelpTimerType HTT ON (T.Type = HTT.Type AND WHERE HTT.lfdLanguage = 0);
LEFT JOIN HelpTimerDayActive HTDA1 ON (T.RunMonday = HTDA1.Active)
LEFT JOIN HelpTimerDayActive HTDA2 ON (T.RunTuesday = HTDA2.Active)
LEFT JOIN HelpTimerDayActive HTDA3 ON (T.RunWednesady = HTDA3.Active)
LEFT JOIN HelpTimerDayActive HTDA4 ON (T.RunThursday = HTDA4.Active)
LEFT JOIN HelpTimerDayActive HTDA5 ON (T.RunFriday = HTDA5.Active)
LEFT JOIN HelpTimerDayActive HTDA6 ON (T.RunSaturday = HTDA6.Active)
LEFT JOIN HelpTimerDayActive HTDA7 ON (T.RunSunday = HTDA7.Active)
;
知道如何将语言选择包含在JOIN中吗?
所有帮助表示赞赏。 感谢
答案 0 :(得分:1)
where子句在所有连接之后:
SELECT DISTINCT
T.lfdTimer,
T.Active,
T.Name,
T.Type, HTT.TText,
T.RunMonday, HTDA1.ACText,
T.RunTuesday, HTDA2.ACText,
T.RunWednesady, HTDA3.ACText,
T.RunThursday, HTDA4.ACText,
T.RunFriday, HTDA5.ACText,
T.RunSaturday, HTDA6.ACText,
T.RunSunday, HTDA7.ACText
FROM
Timer T
INNER JOIN HelpTimerType HTT ON (T.Type = HTT.Type)
LEFT JOIN HelpTimerDayActive HTDA1 ON (T.RunMonday = HTDA1.Active)
LEFT JOIN HelpTimerDayActive HTDA2 ON (T.RunTuesday = HTDA2.Active)
LEFT JOIN HelpTimerDayActive HTDA3 ON (T.RunWednesady = HTDA3.Active)
LEFT JOIN HelpTimerDayActive HTDA4 ON (T.RunThursday = HTDA4.Active)
LEFT JOIN HelpTimerDayActive HTDA5 ON (T.RunFriday = HTDA5.Active)
LEFT JOIN HelpTimerDayActive HTDA6 ON (T.RunSaturday = HTDA6.Active)
LEFT JOIN HelpTimerDayActive HTDA7 ON (T.RunSunday = HTDA7.Active)
WHERE HTT.lfdLanguage = 0
;
答案 1 :(得分:0)
删除
WHERE
来自你的内连接,这是错误的语法。