2012-02-17 44 views
-1

查询结果是select * from table1 where col in(?)。如果在这里使用动态输入(?),如果我这样使用,它会显示错误如何动态地给“”输入“”。如何给查询提供动态输入?

+0

“动态”如何?信息从哪里来?什么编程语言?你为什么不输入信息?什么错误? – 2012-02-17 13:51:52

+0

[PreparedStatement IN clause alternatives options?](http://stackoverflow.com/q/178479/),[MySQL Prepared statement with a variable size variable list](http://stackoverflow.com/q/327274/) ),[参数化SQL IN子句?](http://stackoverflow.com/q/337704/),[使用IN()函数准备MySQL语句](http://stackoverflow.com/q/7158078/) – outis 2012-02-18 08:42:58

回答

0

你想替换吗?有多个值或单个值?如果要用多个值替换它,则不能使用预准备语句,但对于单个值,可以使用准备好的语句。

+0

我想给动态输入(如1,2,3)与in。 – 2012-02-17 11:56:48

0

它被称为prepared statements。如何给它提供输入取决于你使用什么平台来连接数据库(语言,连接器库等)。

如果您试图从数据库控制台执行您的查询,那么您很可能无法执行此操作。在数据库控制台中使用准备好的语句并没有多大意义,当您传递某些用户的输入(即在您的应用程序中)时,它非常有用。

+0

只是我想在工具中执行如何将输入传递给 – 2012-02-17 11:57:58

+0

如果您手动执行查询,则没有意义使用准备好的陈述你可以写'select * from table1 where col('onevalue','anothervalue')'。 – penartur 2012-02-17 12:00:14

+0

select * from table1 where col in(here how to give dynamic input) – 2012-02-17 12:03:21