954,560 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to use less than operators with wild card using mssql?

Hi,
can anybody, please help me out.

<strong>select * from log where id <='%07%' </strong>


Am facing the syntax error, what is the actual query?

my id look like this:
1.mtg10kl
2.mtg07kl
3.mtg06kl
4.mtg09kl

I need the output this:
1.mtg07kl
2.mtg06kl

please help me out .thanks in advance

jacksantho
Junior Poster
163 posts since Feb 2011
Reputation Points: 7
Solved Threads: 0
 

first of all, the percentage sign should have gone with the 'Like' wildcard. from your id's, you wont even get an answer if you had no errors because the comparison operator would search for exactly whats on the right side of the query but using the 'LIKE' keyword would produce A better result

Netcode
Veteran Poster
1,021 posts since Jun 2009
Reputation Points: 43
Solved Threads: 67
 

hi please give me query....

jacksantho
Junior Poster
163 posts since Feb 2011
Reputation Points: 7
Solved Threads: 0
 

There isn't a way to do what you are asking. LIKE won't work since you are looking for <=.
What you can do based on your sample is substring like this:

select * from log where convert(int,substring(log,4,2)) <= 7


You also can try your luck without the conversion to int.

adam_k
Practically a Posting Shark
803 posts since Jun 2011
Reputation Points: 256
Solved Threads: 149
 

hi, thanks...i got it , what i need.

jacksantho
Junior Poster
163 posts since Feb 2011
Reputation Points: 7
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You