次の準備済みステートメントを実行できません。
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)
よろしく、
ラビ。