我有一个只包含以下内容的proc:
SELECT Col1, Col2 FROM table WHERE Id = 1;
这总是返回空值。如果我将语句更改为:
SELECT Id, Col1, Cold2 FROM table WHERE Id = 1;
按预期返回行。 mySql是否要求where子句列出现在选择列表中?在phpMyAdmin中直接运行SQL时,它没有此行为。
以下是相关代码:
CREATE PROCEDURE sp_player_login
(
IN
userGraphId INT(11),
authToken TEXT
)
BEGIN
DECLARE playerId INT;
DECLARE newPlayer BOOLEAN DEFAULT FALSE;
SELECT Id INTO playerId FROM player WHERE FacebookGraphId = userGraphId;
If playerId IS NULL THEN
-- Create the player.
SET newPlayer = TRUE;
-- Get new player defaults.
SELECT NewPlayerTurns, NewPlayerMoney, NewPlayerMorale, NewPlayerMissilePower FROM defaults WHERE Id = 1;
END IF;
END #
第二个SELECT NewPlayerTurns ...如果我没有在select子句中指定Id列,则返回null值。如果我删除第一个SELECT Id INTO ...第二个查询在select子句中没有Id工作...? 混淆