469,076 Members | 1,402 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,076 developers. It's quick & easy.

IN Clause in Dynamic Query

Hi,

I am writing a dynamic query in which i have to select a records depend upon the no. of values entered by user like:
select * from _table where _tableColumn IN (values entered by user)

the values entered come in this format: 456,465,123
bt if i pass this value in string format through a bind variable. The query is not working it is taking whole value as whole..

Please help me out..
I am writing this query in MySql
Apr 22 '07 #1
2 6312
Hi,

I am writing a dynamic query in which i have to select a records depend upon the no. of values entered by user like:
select * from _table where _tableColumn IN (values entered by user)

the values entered come in this format: 456,465,123
bt if i pass this value in string format through a bind variable. The query is not working it is taking whole value as whole..

Please help me out..
I am writing this query in MySql


hi...

for do this, u have to use the dynamic sql.
For example:

user input value is 456,465,123....

first build the query lie this

set @vquery = CONCAT("select * from test_table where table_col in(","456,465,123",")");

prepare stmt from @vquery;
execute stmt;


Regards,
S.Ashokkumar
Apr 23 '07 #2
Hi,

Try this

SET @vValue := '456,465,123';

SET @vquery = CONCAT('select * from test_table where table_col in (', @vValue,');


PREPARE stmt from @vquery;
EXECUTE stmt;


Thanks,
Pimp


Hi,

I am writing a dynamic query in which i have to select a records depend upon the no. of values entered by user like:
select * from _table where _tableColumn IN (values entered by user)

the values entered come in this format: 456,465,123
bt if i pass this value in string format through a bind variable. The query is not working it is taking whole value as whole..

Please help me out..
I am writing this query in MySql
Apr 23 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Rodusa | last post: by
4 posts views Thread by Brian Shannon | last post: by
10 posts views Thread by John | last post: by
1 post views Thread by john | last post: by
6 posts views Thread by Plissskin | last post: by
reply views Thread by Jay Douglas | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.