If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Beginner looking for help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-27-03, 21:07
bmas bmas is offline
Registered User
 
Join Date: Oct 2003
Posts: 2
Beginner looking for help

Hi All,

I'm not very good at SQL but I want to finish my ASP project and have run into a little problem. I have a variable that I formatted represent a nice comma delimited character list with all "words" in single quotes ('A','B','C'). I was going to pass this variable to a SELECT statement -

SELECT col FROM table WHERE item IN (<my variable>)

Am I doing this right?

Thanks!

B
Reply With Quote
  #2 (permalink)  
Old 10-28-03, 02:22
cvandemaele cvandemaele is offline
Registered User
 
Join Date: Oct 2003
Location: Switzerland
Posts: 140
I don't think this will work. The IN clause will try to match all values of column ITEM with the complete string that your variable represents. There are a lot of ways to handle this, one would be to use dynamic SQL. What database are you working with ?

Another would be to use specific functions that allow to search for a character (pattern) within another string. Again, the solution will depend on your database.
Reply With Quote
  #3 (permalink)  
Old 10-28-03, 12:15
bmas bmas is offline
Registered User
 
Join Date: Oct 2003
Posts: 2
Quote:
Originally posted by cvandemaele
I don't think this will work. The IN clause will try to match all values of column ITEM with the complete string that your variable represents. There are a lot of ways to handle this, one would be to use dynamic SQL. What database are you working with ?

Another would be to use specific functions that allow to search for a character (pattern) within another string. Again, the solution will depend on your database.
Thanks. I learned the dynamic SQL way last night shortly after posing this.

I appreciate your resonse!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On