问题描述
我希望它显示所有JK罗琳·哈利·波特系列书籍,但由于某种原因,它只显示第一本书。我该如何解决? select语句中似乎有一个错误,但是我似乎无法找出它是什么。可以帮忙吗?我只想在引号中输入随机词,因为stackoverflow表示我的帖子主要是代码,我需要添加更多详细信息。
create table authors (id integer primary key autoincrement,fullname TEXT,language TEXT,birthdate integer,deathdate integer,books integer,notes text);
insert into authors (fullname,language,birthdate,deathdate,books) values ("William Shakespeare","English",1564,1616,39);
insert into authors (fullname,books) values ("J. K. Rowling",1965,15);
insert into authors (fullname,books,notes) values ("Gordon Korman",1963,82,"Only favorite books");
create table books (author_id integer,name text,publish_year integer);
insert into books VALUES (1,"The Two Gentlemen of Verona",1589);
insert into books VALUES (1,"The Comedy of Errors",1589);
insert into books VALUES (1,"Titus Andronicus",1591);
insert into books VALUES (1,"The Taming of The Shrew",1593);
insert into books VALUES (1,"love Labours Lost",1589);
insert into books VALUES (1,"Romeo and Juliet",1594);
insert into books VALUES (1,"A Midsummer's Night's Dream",1595);
insert into books VALUES (1,"King John","The Merchant of Venice",1596);
insert into books VALUES (1,"The Merry Wives of Windsor",1597);
insert into books VALUES (1,"Much Ado About nothing",1598);
insert into books VALUES (1,"As You Like It",1599);
insert into books VALUES (1,"Julius Caesar","Troilus and Cressida",1600);
insert into books VALUES (1,"Hamlet","Twelfth Night or What You Will",1601);
insert into books VALUES (1,"All's Well That Ends Well",1603);
insert into books VALUES (1,"Measure for Meausre","othello","Timon of athens",1604);
insert into books VALUES (1,"King Lear",1605);
insert into books VALUES (1,"Macbeth",1606);
insert into books VALUES (1,"Pericles",1607);
insert into books VALUES (1,"Antony and Cleopatra",1608);
insert into books VALUES (1,"Coriolanus","Cymbeline",1609);
insert into books VALUES (1,"The Winter's Tale","The Tempest",1610);
insert into books VALUES (1,"The Two Noble Kinsmen",1611);
insert into books VALUES (1,"Cardenio",1612);
insert into books VALUES (1,"Henry VIII",1613);
insert into books VALUES (1,"Henry V","Richard III","Richard II",1595);
insert into books VALUES (2,"Fantastic Beasts and Where to Find Them",2001);
insert into books VALUES (2,"Quidditch Through the Ages","The Tales of Beedle the Bard",2008);
insert into books VALUES (2,"Hogwarts: An Incomplete & Unreliable Guide",2016);
insert into books VALUES (2,"Short Stories from Hogwarts of Heroism,Hardship and Dangerous Hobbies","Short Stories from Hogwarts of Power,Politics and Pesky Poltergeists",2016);
insert into books VALUES (3,"Losing Joe's Place",1990);
insert into books VALUES (3,"The Sixth Grade Nickname Game",1998);
insert into books VALUES (3,"Schooled",2007);
insert into books VALUES (3,"The Juvie Three",2008);
insert into books VALUES (3,"Ungifted",2012);
insert into books VALUES (3,"Restart",2018);
insert into books VALUES (3,"Whatshisface","The Unteachbles",2019);
insert into books VALUES (3,"Notorius",2020);
select authors.fullname as Author,books.name as "Name",books.publish_year as "Year Published" from books left outer join authors on books.author_id = authors.id;
create table series (id integer primary key autoincrement,series_id text,name_book text);
insert into series (series_id,name_book) VALUES("1-1","Henry VI,Part One");
insert into series (series_id,Part Two");
insert into series (series_id,Part Three");
insert into series (series_id,name_book) VALUES("1-2","Henry IV,name_book) VALUES("2-1","Harry Potter and the Philosopher's Stone");
insert into series (series_id,name_book) VALUES("2-2","Harry Potter and the ChAmber of Secrets");
insert into series (series_id,name_book) VALUES("2-3","Harry Potter and the Priosner of Azkaban");
insert into series (series_id,name_book) VALUES("2-4","Harry Potter and the Goblet of Fire");
insert into series (series_id,name_book) VALUES("2-5","Harry Potter and the Order of the Phoenix");
insert into series (series_id,name_book) VALUES("2-6","Harry Potter and the Half-Blood Prince");
insert into series (series_id,name_book) VALUES("2-7","Harry Potter and the Deathly Hallows");
insert into series (series_id,name_book) VALUES("2-8","Harry Potter and the Cursed Child,Parts I & II");
insert into series (series_id,name_book) VALUES("3-1","Slacker");
insert into series (series_id,"Level 13");
insert into series (series_id,name_book) VALUES("3-2","Masterminds");
insert into series (series_id,"Criminal Destiny");
insert into series (series_id,"Payback");
insert into series (series_id,name_book) VALUES("3-3","The Hypnotists");
insert into series (series_id,"Memory Maze");
insert into series (series_id,"The Dragonfly Effect");
insert into series (series_id,name_book) VALUES("3-4","Ungifted");
insert into series (series_id,"Supergifted");
create table series_id (author_id integer,series_name text,books_in_series integer,start_year integer);
insert into series_id VALUES (1,"1-1","Henry VI",3,1590);
insert into series_id VALUES (1,"1-2","Henry IV",2,1596);
insert into series_id VALUES (2,"2-1","Harry Potter",8,1997);
insert into series_id VALUES (3,"3-1","Slacker",2016);
insert into series_id VALUES (3,"3-2","Masterminds",2015);
insert into series_id VALUES (3,"3-3","The Hypnotists",2013);
insert into series_id VALUES (3,"3-4",2012);
select authors.fullname,series_id.series_name,series_id.books_in_series,series_id.start_year,series.id,series.name_book from series_id join authors on series_id.author_id = authors.id join series on series_id.series_id = series.series_id order by series.id;
解决方法
author_id = 2
只有1个联接,并且在series_id = "2-1"
上:
insert into series_id VALUES (2,"2-1","Harry Potter",8,1997);
insert into series (series_id,name_book) VALUES("2-1","Harry Potter and the Philosopher's Stone");
您似乎在将多个内容塞入series_id
中,即实际的series_id和序列中的序列。我建议您为每个概念创建单独的列。
请参见First Normal Form-列中只能包含1个值。