944,098 Members | Top Members by Rank

Ad:
  • MS SQL Discussion Thread
  • Unsolved
  • Views: 2878
  • MS SQL RSS
Jul 10th, 2006
0

Question about SQL statement

Expand Post »
I have a question about the possible string match in sql statement, for example I have variable "$val=abc", I can write:
MS SQL Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
michael123 is offline Offline
93 posts
since Jun 2005
Sep 14th, 2006
0

Re: Question about SQL statement

michael,


in this case you should write this.

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

this should work

thanks,
chaitanya
Reputation Points: 11
Solved Threads: 1
Light Poster
chmonalisa is offline Offline
26 posts
since Sep 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MS SQL Forum Timeline: Join 3 tables
Next Thread in MS SQL Forum Timeline: Views in SQL





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC