表1:如下CREATE TABLE student (sid integer, sname text, age integer);sqlite> select * from student;1|zhang|222|li|213|wang|194|xue|195|zhao|20表2:如下CREATE TABLE achievements (cid integer, sid integer, course text, results integer);2|1|shuxue|854|2|shuxue|906|3|shuxue|828|4|shuxue|7210|5|shuxue|100我要查询年龄为20的学生的成绩该怎么写连接sql语句???sqlite> select a.results from achievements as a inner join student as s where s.age=20;85908272100为什么上面的语句查出来的不是100这个数,而是把所有的成绩全打出来了??正确的语句该怎么写???
1 回答
MM们
TA贡献1886条经验 获得超2个赞
少一个连接条件
select a.results from achievements as a inner join student as s where s.age=20;
改为
select a.results from achievements as a inner join student as s on a.sid = s.sid where s.age=20;
- 1 回答
- 0 关注
- 515 浏览
添加回答
举报
0/150
提交
取消