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.
Asked
Active
Viewed 468 times
-1

Mark Coleman
- 40,542
- 9
- 81
- 101

Mariya Selvam
- 9
- 1
- 6
-
"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 Answers
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
-
-
If you're executing the query manually, there is no point in using prepared statements. You can just write `select * from table1 where col in('onevalue', 'anothervalue')`. – penartur Feb 17 '12 at 12:00
-
select * from table1 where col in(Here how to give dynamic input) – Mariya Selvam Feb 17 '12 at 12:03
-
-
@MariyaSelvam: Instead of repeating yourself (and "how to give dynamic input" is meaningless, especially if you're entering this query by hand?!) _explain what problem you're having_. – Lightness Races in Orbit Feb 17 '12 at 13:52