刪除并且返回值,我試了三個表,都是類似的錯誤,求大神幫忙看看
mysql> SELECT * FROM users5;
+----+----------+----------+-----+------+
| id | username | password | age | sex? |
+----+----------+----------+-----+------+
|? 1 | TOM? ? ? | 123? ? ? |? 10 |? ? 0 |
|? 2 | John? ? ?| 123? ? ? |? 23 |? ? 1 |
+----+----------+----------+-----+------+
2 rows in set (0.03 sec)
mysql> DESC users5;
+----------+----------------------+------+-----+---------+----------------+
| Field? ? | Type? ? ? ? ? ? ? ? ?| Null | Key | Default | Extra? ? ? ? ? |
+----------+----------------------+------+-----+---------+----------------+
| id? ? ? ?| smallint(5) unsigned | NO? ?| PRI | NULL? ? | auto_increment |
| username | varchar(20)? ? ? ? ? | NO? ?|? ? ?| NULL? ? |? ? ? ? ? ? ? ? |
| password | varchar(32)? ? ? ? ? | NO? ?|? ? ?| NULL? ? |? ? ? ? ? ? ? ? |
| age? ? ? | tinyint(3) unsigned? | NO? ?|? ? ?| 10? ? ? |? ? ? ? ? ? ? ? |
| sex? ? ? | tinyint(1)? ? ? ? ? ?| YES? |? ? ?| NULL? ? |? ? ? ? ? ? ? ? |
+----------+----------------------+------+-----+---------+----------------+
5 rows in set (0.00 sec)
mysql> DELIMITER //
mysql> CREATE PROCEDURE removeAndReturn(IN u_id INT UNSIGNED,OUT users5nums INT UNSIGNED)
? ? -> BEGIN
? ? -> DELETE FROM users5 WHERE id = T_id;
? ? -> SELECT count(id) FROM users5 INTO users5nums;
? ? -> END
? ? -> //
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNSIGNED)
BEGIN
DELETE FROM users5 WHERE id = T_id;
SELECT count(id) FROM user' at line 1
2019-03-07
問題找到了,謝謝,是第一行括號打成中文的了
2019-03-05
傳的是u_id? ?,接收的T_id哪來的? ?WHERE id = T_id