如何使用SQLite表/查询?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (1)
  • 关注 (0)
  • 查看 (39)

我有这些表的SQLite3数据库:

Match(
id integer PRIMARY KEY, 
map varchar(20), 
date varchar(40), 
waitTime integer, 
duration integer, 
teamAScore integer, 
teamBScore integer, 
victory integer
)

Player(
id integer PRIMARY KEY, 
steamID varchar(20), 
name varchar(40), 
commonMatches integer, 
you boolean
)

MatchPlayer(
match_id integer, 
player_id integer, 
ping integer, 
kills integer, 
assists integer, 
deaths integer, 
mvps integer, 
hsp integer, 
score integer, 
teammate integer, 
FOREIGN KEY (match_id) REFERENCES Match(id), 
FOREIGN KEY (player_id) REFERENCES Player(id)
)

查询:

SELECT * FROM MatchPlayer, Player WHERE MatchPlayer.player_id = 1;

但是,当我尝试

SELECT * FROM MatchPlayer, Player WHERE MatchPlayer.player_id = 26;
提问于
用户回答回答于

问题在于SQLite从1开始索引,我从0开始,这意味着我通过搜索ID 25来获得我的朋友(ID 26)统计信息。

扫码关注云+社区

领取腾讯云代金券