private final Map<Integer, Lobby> lobbiesByID;
private boolean isPlayerInLobby(Player player) {
return lobbiesByID.values().stream().anyMatch(l -> l.hasPlayer(player));
}
public IRemotePublisherForListener connect(Player player, int lobbyID) {
if(!isPlayerInLobby(player)) {
//.. insert null-check unless you trust the id
lobbiesByID.get(lobbyID).addPlayer(player);
}
//.. else, log an error, or throw
return publisher;
}
答案 0 :(得分:2)
正确形成的SQL查询只有一个where
子句(不包括CTE和子查询)。所以:
select *
from table1 a LEFT OUTER JOIN
(select *
from table99
where col = 1
) b
ON a.col1 = b.col1 AND
a.col2 = b.col2 LEFT OUTER JOIN
(select *
from table99
where col = 2
) c
ON a.col1 = c.col1 AND
a.col2 = c.col2
WHERE SIGN(a.col3) = 1;
然而,这似乎太复杂了。怎么样?
select *
from table1 a LEFT OUTER JOIN
table99 b
ON a.col1 = b.col1 AND
a.col2 = b.col2 AND
b.col = 1 LEFT OUTER JOIN
table99 c
ON a.col1 = c.col1 AND
a.col2 = c.col2 AND
c.col = 2
WHERE a.col3 > 0;
答案 1 :(得分:0)
我认为你不需要在这句话ON (a.col1 = b.col1)
中使用括号,我同意戈登的意见,你应该梳理你的观点和地点