我有两个表像这样:加入表的SQL不是无效
create table classe (
id integer primary key,
name varchar not null
);
create table alunno (
id integer primary key,
id_classe integer not null
);
我会采取一种独特的查询以下数据:
- classe.id
- classe.name
- alunno有一个特定的计数id_classe
这样我就可以做这样的事情:
select a.id, a.name, count(b.id)
from classe a, alunno b
where a.id = :1 and b.id_classe = a.id;
但如果计数= 0我在resultset..so空值我向始终节记录的信息,如果没有一个alunno记录存在该节我会计数= 0,不会使整个输出失效。如何获得这个结果集?
我也试图与左加入,但可能是错误的结构性..
我补充一点,我使用的SQLite所以一些SQL命令不能在它被用来
非常感谢你的帮助。