Question about SQL statement

Please support our MS SQL advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2005
Posts: 92
Reputation: michael123 is an unknown quantity at this point 
Solved Threads: 0
michael123 michael123 is offline Offline
Junior Poster in Training

Question about SQL statement

 
0
  #1
Jul 10th, 2006
I have a question about the possible string match in sql statement, for example I have variable "$val=abc", I can write:
  1. SELECT * FROM TABLE WHERE FIELD LIKE '%$val%'
this will list all recoreds that the field contains sub-string "abc".
Now the question is: if I have a string for example "$val=893abc82", is it possible to "partial match" the field in sql statement and populate the same records? in other words, if the DB field data has the same substring as those from the variable, then list those records? is it possible? thanks for any advice.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 26
Reputation: chmonalisa is an unknown quantity at this point 
Solved Threads: 1
chmonalisa chmonalisa is offline Offline
Light Poster

Re: Question about SQL statement

 
0
  #2
Sep 14th, 2006
michael,


in this case you should write this.

SELECT * FROM table WHERE charindex('abc',field)>0

this should work

thanks,
chaitanya
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the MS SQL Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC