将以下查询发送到我的数据库时:
SELECT statemachines.statemachinename,
states.statename,
actionhandlers.actionhandler,
actions.value, actions.sourcename
FROM actions, actionhandlers, states, statemachines
INNER JOIN rules ON (actions.rule_id AND rules.rule_id)
INNER JOIN actionhandlers ON (actions.actionhandler AND actionhandlers.actionhandler)
INNER JOIN states ON (states.state_id AND actions.state_id)
INNER JOIN statemachines ON (states.statemachinename AND statemachines.statemachinename)
WHERE (rules.eventname = 'PIR') AND (statemachines.currentstate = states.state_id)
返回以下错误:
android.database.sqlite.SQLiteException: ambiguous column name: statemachines.statemachinename (code 1): , while compiling:
我不知道该做什么,我的所有其他查询都有效。
答案 0 :(得分:4)
您使用statemachines
两次。一旦进入JOIN子句,一次进入FROM。
命名其中一个:
...
FROM actions, actionhandlers, states, statemachines AS statemachines1
...
答案 1 :(得分:2)
简化:FROM actions, actionhandlers, states, statemachines
=> FROM actions