表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的學(xué)生的成績該怎么寫連接sql語句???sqlite> select a.results from achievements as a inner join student as s where s.age=20;85908272100為什么上面的語句查出來的不是100這個(gè)數(shù),而是把所有的成績?nèi)虺鰜砹???正確的語句該怎么寫???
1 回答

MM們
TA貢獻(xiàn)1886條經(jīng)驗(yàn) 獲得超2個(gè)贊
少一個(gè)連接條件
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 關(guān)注
- 553 瀏覽
添加回答
舉報(bào)
0/150
提交
取消