I am trying to get the IDs of half of the good players, but only those contained in node_id=28
" SELECT * FROM
(SELECT npid.player_id
FROM node_to_player_ids npid
INNER JOIN players_gameplay_info pg
ON npid.player_id = pg.player_id
WHERE npid.node_id = 28
ORDER BY pg.score_collected ASC) AS selectedPlayers
LIMIT (SELECT COUNT(*) FROM selectedPlayers) / 2"
There will be approximately 1000 000 entries to count, so I wanted to store it in a variable, however, we cannot store multiple rows in the one like @myLocalVariable
Only one record could be stored. However, it should be possible to interpret the selection AS selectedPlayers
That way I hoped I would re-use the obtained mass of player_ids and iterate over them rather than performing the same selection query just to count half the records
However, I am getting an error
'SQLSTATE[42000]: Syntax error or access violation: 1064 near '(SELECT COUNT(*) FROM selectedPlayers) / 2' at line 10'
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…