为什么我不能在子查询中执行简单计数?

时间:2015-09-07 16:35:15

标签: android sql sqlite

我正在尝试编写一个简单的查询来获取特定表的所有列,但也会添加相关表中的行数。

以下是查询:

if lsvg -l appvg | awk 'NR > 2 && $3 != $4 { exit 1 } END {exit 0}'; then
  echo "Columns matched in each line"
else
  echo "Columns were different in some lines"
fi

这是错误:

SELECT 
   todos.*, 
   (SELECT COUNT(assets.*) FROM assets WHERE assets.parent_id = todos._id) AS asset_count 
FROM todos

1 个答案:

答案 0 :(得分:2)

尝试替换COUNT(assets.*)COUNT(*)

COUNT(assets._id)

我的第二个建议,尝试运行内部选择就像一个

SELECT COUNT(*) FROM assets WHERE assets.parent_id = 1 <-- any _id you have