mysql> select * from CT;
| CID | MID | REPORT_QUERY |
| 1 | 1 | select * from emp; |
| 2 | 2 | select * from student; |
2 rows in set (0.00 sec)
我想在REPORT_QUERY
列執行查詢。如何執行存儲在表列MySQL中的查詢?
DELIMITER //
CREATE PROCEDURE TRYct()
BEGIN
SET @str=(SELECT GROUP_CONCAT(REPORT_QUERY SEPARATOR ' ') FROM CT);
PREPARE q from @str;
EXECUTE q;
END //
DELIMITER ;
我用這個代碼,但它的工作原理,如果只有一個在我的表查詢。如果有兩個查詢比它給出一個錯誤。
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 'select * from student' at line 1
問題在哪裏?幫我。
@伊萬Cachicatari .....謝謝主席先生 –
@JaniHarsh你的歡迎,請考慮接受並給予好評我的答案:) –