我正在努力,现在由于WHERE子句出错而停止。找不到解决这个问题的办法。如果我做SELECT * FROM booking_customer WHERE date_booking_customer = date_input AND time_booking_customer = time_input;
,它的效果很好,但和其他的一起,在哪里前面有一个变化。。。
CREATE DEFINER=`root`@`localhost`
PROCEDURE `book_service`(
date_input DATE,
time_input TIME,
name_input VARCHAR (200),
member_input TINYINT,
boatname_input VARCHAR (200),
email_input VARCHAR (200),
mobile_input VARCHAR (200)
)
BEGIN
INSERT INTO booking_customer(
name_booking_customer,
member_booking_customer,
boatname_booking_customer,
mail_booking_customer,
mobile_booking_customer)
VALUES (
name_input,
member_input,
boatname_input,
email_input,
mobile_input)
WHERE date_booking_customer = date_input
AND time_booking_customer = time_input;
END
/Svante
我不完全确定您试图用WHERE子句实现什么,但INSERT语句不能与WHERE关联。
这看起来有点像您正在尝试更新一行,其中date_booking_customer=date_input和time_booking_client=time_input。如果这就是你想要做的,你可以这样做:
UPDATE booking_customer
SET
name_booking_customer = name_input,
member_booking_customer = member_input,
boatname_booking_customer = boatname_input,
mail_booking_customer = email_input,
mobile_booking_customer = mobile_input
WHERE
date_booking_customer = date_input
AND time_booking_customer = time_input;
请参阅SQL INSERT INTO语句,https://www.w3schools.com/sql/sql_insert.asp.INSET INTO语句不包括"WHERE"。
在一个程序中,
IF expression THEN commands
[ELSEIF expression THEN commands]
[ELSE commands]
END IF;
例如
IF date_booking_customer == date_input
AND time_booking_customer == time_input then
...
End If;