Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设有一个简单的查询::
String College="Harvard" SELECT * FROM College
查询将失败,因为系统假设 College 作为表的名称并搜索它不存在
如何解决这个....就SQL语句而言
希望我清楚
谢谢,
像这样尝试怎么样:)
SET @College:='Harvard'; SET @sql_text = concat('SELECT * FROM ', @College) PREPARE stmt FROM @sql_text; EXECUTE stmt; DEALLOCATE PREPARE stmt;