0

这个说法有什么问题?

IF EXISTS (
SELECT * 
FROM `apples` 
WHERE `apples`.`color` = ? 
AND `apples`.`size` = ?) 
SELECT `apples`.`applesID` 
ELSE 
INSERT INTO `apples` (`color`, `size`) 
VALUES(?,?);
4

1 回答 1

0

您没有为IF使用正确的语法:

IF EXISTS (
    SELECT * 
    FROM `apples` 
    WHERE `apples`.`color` = ? 
    AND `apples`.`size` = ?) THEN
    SELECT `apples`.`applesID`;
ELSE 
    INSERT INTO `apples` (`color`, `size`) VALUES(?,?);
END IF;
于 2013-04-24T10:50:39.087 回答