-1

The query is select * from table1 where col in(?) .how to give dynamic input here(?) if i used like this it shows error how give input to the "in" dynamically.

Mark Coleman
  • 40,542
  • 9
  • 81
  • 101
  • "Dynamic" how? Where will the information come from? What programming language? Why don't you type the information in? What error? – Lightness Races in Orbit Feb 17 '12 at 13:51
  • possible duplicate of [PreparedStatement IN clause alternatives?](http://stackoverflow.com/q/178479/), [MySQL Prepared statements with a variable size variable list](http://stackoverflow.com/q/327274/), [Parameterizing an SQL IN clause?](http://stackoverflow.com/q/337704/), [Prepare MySQL statement with IN() function](http://stackoverflow.com/q/7158078/) – outis Feb 18 '12 at 08:42

2 Answers2

0

Do you want to replace ? with multiple values or a single value? If you want to substitute it with multiple values you can not use a prepared statement, but for a single value you can use a prepared statement.

Amir Pashazadeh
  • 7,170
  • 3
  • 39
  • 69
0

It is called prepared statements. How to give an input to it depends on what platform are you using to connect to DB (language, connector library etc).

If you're trying to execute your query from the DB console, then you'll likely be unable to do it. And using prepared statements in the DB console doesn't make much sense overall, it is useful when you're passing in some user's input (that is, in your application).

penartur
  • 9,792
  • 5
  • 39
  • 50