我尝试了各种方法。这对我来说很有意义,但是当我尝试执行时insert into listsandplayers
,它告诉我不listID
存在列。我用我的insert into listsandplayers
陈述尝试了几种不同的方法,并继续得到这个错误。
我已经在这里发布了我认为该声明应该最有效的方式。这是此处显示的最后一条语句。
CREATE TABLE IF NOT EXISTS
lists (listID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, listName VARCHAR(30));
CREATE TABLE IF NOT EXISTS
players(playerID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, playerName VARCHAR);
CREATE TABLE IF NOT EXISTS
listsandplayers(listsandplayersID INTEGER NOT NULL,
listID INTEGER REFERENCES lists (listID),
playerID INTEGER REFERENCES players (playerID));
INSERT INTO lists (listName) VALUES('Los Angeles Dodgers');
INSERT INTO players (playerName) VALUES('Clayton Kershaw');
INSERT INTO listsandplayers (listID, playerID) VALUES(listID, playerID)
WHERE listName = 'Los Angeles Dodgers'
AND playerName = 'Clayton Kershaw'
NATURAL JOIN lists
NATURAL JOIN players;