假设我每 2 秒执行一次查询,我应该在每个请求上打开连接,还是应该保持连接处于活动状态直到应用程序(服务器)停止?
我需要有关sql查询的帮助.
我有这两个表:
player_locations:
ID | playerid | location <- unqiue key
---|-----------------------
1 | 1 | DOWNTOWN
Run Code Online (Sandbox Code Playgroud)
和 users:
ID | playername | [..]
----|--------------------
1 | example1 | ...
Run Code Online (Sandbox Code Playgroud)
我需要一个选择,以获得users.playername
从player_locations.playerid
.我有独特的地理位置player_locations.playerid
.
伪查询:
SELECT playername
FROM users
WHERE id = player_locations.playerid
AND player_locations.location = "DOWNTOWN";
Run Code Online (Sandbox Code Playgroud)
输出应该是example1
.