“SQL query to match the data in the passed comma sepearted string”

March 26, 2008

There are several occasions when we have to match whether a passed collection of id is there in the database or not , in this case we can design the SQL in such a fashion that it checks for the id = (1,2,3), so for that we need to use IN operator.

Eg:
select * from table_name where table_name.id IN (array of integer or anything else)
Now here the array of integer or anything else should be in a comma separated manner like (1,2,3) or (’asa’,’sa’,’sasa’)

Entry Filed under: SQL, mysql. Tags: , , , .

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Recent Posts

Archives

Category Cloud

Active Record active scaffold ajax calendar date select capistrano deployment edge rails formula 1 2008 For those who dont want to update the prototype.js Framesets vs iFrames fun html javascript mysql plugin rails regexp ror Ruby ruby on rails ruy on rails SQL string functions Text Area they can checkout 1.8.3 of the calender date select titleize titleize vs capitalize tutorial Uncategorized validations

Tags

Links

Meta

Pages

Calendar

March 2008
M T W T F S S
« Feb   Apr »
 12
3456789
10111213141516
17181920212223
24252627282930
31