0

我有这个 SQL 代码:

SELECT t1.offname, t2.offname, t3.offname, t4.offname, t5.offname, t6.offname, t7.offname
FROM AS_ADDROBJ_29 t1
LEFT JOIN AS_ADDROBJ_29 t2 ON t1.parentguid = t2.aoguid AND t1.parentguid NOT NULL
LEFT JOIN AS_ADDROBJ_29 t3 ON t2.parentguid = t3.aoguid AND t2.parentguid NOT NULL
LEFT JOIN AS_ADDROBJ_29 t4 ON t3.parentguid = t4.aoguid AND t3.parentguid NOT NULL
LEFT JOIN AS_ADDROBJ_29 t5 ON t4.parentguid = t5.aoguid AND t4.parentguid NOT NULL
LEFT JOIN AS_ADDROBJ_29 t6 ON t5.parentguid = t6.aoguid AND t5.parentguid NOT NULL
LEFT JOIN AS_ADDROBJ_29 t7 ON t6.parentguid = t7.aoguid AND t6.parentguid NOT NULL
WHERE t1.offname LIKE "smth%"

当我使用 执行此操作时SQLiteManager,它返回 7 列,其中一些列等于 null。但是 AIR 只返回最后一个t7表结果,其他结果被省略。不同SQLColumnNameStyle-s的情况不会改变。

有任何想法吗?

4

1 回答 1

0

加入同一个表有一个问题 - 结果你得到很多同名的列。AIR sqlite 引擎无法正确处理它,但有一个简单的技巧:您应该用不同的字符串名称命名所有列。像这样:

SELECT t1.offname AS 'OFFNAME1', t2.offname AS 'OFFNAME2', t3.offname AS 'OFFNAME3', 
t4.offname AS 'OFFNAME4', t5.offname AS 'OFFNAME5', t6.offname AS 'OFFNAME6',
t7.offname AS 'OFFNAME7'
FROM AS_ADDROBJ_29 t1
LEFT JOIN AS_ADDROBJ_29 t2 ON t1.parentguid = t2.aoguid AND t1.parentguid NOT NULL
LEFT JOIN AS_ADDROBJ_29 t3 ON t2.parentguid = t3.aoguid AND t2.parentguid NOT NULL
LEFT JOIN AS_ADDROBJ_29 t4 ON t3.parentguid = t4.aoguid AND t3.parentguid NOT NULL
LEFT JOIN AS_ADDROBJ_29 t5 ON t4.parentguid = t5.aoguid AND t4.parentguid NOT NULL
LEFT JOIN AS_ADDROBJ_29 t6 ON t5.parentguid = t6.aoguid AND t5.parentguid NOT NULL
LEFT JOIN AS_ADDROBJ_29 t7 ON t6.parentguid = t7.aoguid AND t6.parentguid NOT NULL
WHERE t1.offname LIKE "smth%"

现在在 SQLResult.data 中,您将拥有带有 7 个“OFFNAME#”键和所有值的对象。一些值将等于 null。

于 2012-07-31T06:36:11.800 回答