我正在编译一个原始语句,我需要将先前的查询结果分配给一个变量并将其用作下一个查询的 id。不幸的是,我不记得如何在 SQL 中做到这一点。
这就是我得到的
01-18 18:22:22.443: E/AndroidRuntime(5801): android.database.sqlite.SQLiteException: near "AS": syntax error (code 1): , while compiling: SELECT _id,date,title,description, (SELECT title FROM discipline WHERE _id=gdid ) AS discipline_title FROM alert WHERE _id=(SELECT eaid FROM alert_to_discipline) AS gdid
我怀疑 AS gdid 是使其成为变量的错误方法。我该怎么做?
这是格式更好的查询
SELECT _id,date,title,description,
(SELECT title FROM discipline WHERE _id=gdid ) AS discipline_title
FROM alert WHERE _id=(SELECT eaid FROM alert_to_discipline) AS gdid