我无法执行以下准备好的声明,
PREPARE stmt FROM 'SELECT sb.id,sb.category,sb.make,sb.name,sb.pic,rs.slot
FRO M studbike AS sb LEFT JOIN reservation AS rs ON
sb.id=rs.studbike_id AND sb.availability=1 AND rs.date=? WHERE
sb.studpoint_id=? ORDER BY category DESC,name DESC';
如果我尝试通过以下方式执行准备好的声明:
SET @sid=1;@date1 ='2012-06-12';
EXECUTE stmt USING @sid,@date1;
我得到了:
mysql> EXECUTE stmt1 USING @sid,@date1;
Empty set, 3 warnings (0.00 sec)
mysql> SHOW WARNINGS ;
+---------+------+------------------------------------------------------+
| Level | Code | Message |
+---------+------+------------------------------------------------------+
| Warning | 1292 | Incorrect date value: '1' for column 'date' at row 1 |
| Warning | 1292 | Incorrect date value: '1' for column 'date' at row 1 |
| Warning | 1265 | Data truncated for column 'studpoint_id' at row 1 |
+---------+------+------------------------------------------------------+
3 rows in set (0.00 sec)
但是我可以通过给出一些值代替它来正常运行它?在select语句中。
mysql> SELECT sb.id,sb.category,sb.make,sb.name,sb.pic,rs.slot
FROM studbike AS sb LEFT JOIN reservation AS rs ON sb.id=rs.studbike_id
AND sb.availability=1 AND rs.date='2012-06-11' WHERE sb.studpoint_id=1
ORDER BY category DESC,name DESC \ G
*************************** 1. row ***************************
id: 2 category: 126-150
make: bajaj
name: pulser
pic: test.gif
slot: NULL
*************************** 2. row ***************************
id: 1 category: 100-125
make: bajaj
name: discover
pic: test.gif
slot: NULL
2 rows in set (0.00 sec)
的问候,
拉维。
答案 0 :(得分:4)
EXECUTE stmt USING @sid,@date1;
应该是
EXECUTE stmt USING @date1,@sid;
订单很重要......