这句话有什么问题?
IF EXISTS (
SELECT *
FROM `apples`
WHERE `apples`.`color` = ?
AND `apples`.`size` = ?)
SELECT `apples`.`applesID`
ELSE
INSERT INTO `apples` (`color`, `size`)
VALUES(?,?);
答案 0 :(得分: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;