467,915 Members | 1,263 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,915 developers. It's quick & easy.

LIKE usage

Hi,

I am doing this query succesfully in MySQL and I wonder why the LIKE does not work the same in MSSQL. Is there any way arround?

MySQL: SELECT * FROM tariffs WHERE '4321' LIKE concat(prefix,'%')

MSSQL: SELECT * FROM tariffs WHERE '4321' LIKE (prefix + '%')

the MSSQL query returns NULL always.
The long workarround is to make a: WHERE prefix = '4321' OR prefix = '432' OR prefix = '43' OR prefix = '4'
but I want to avoid this.

Anybody knows a workaround?

Thanks
Oct 22 '08 #1
  • viewed: 1441
Share:
2 Replies
Ok, I found the solution.
Using RTRIM like this it works:

SELECT * FROM tariffs WHERE '4321' LIKE RTRIM(prefix) + '%'
Oct 22 '08 #2
ck9663
Expert 2GB
Ok, I found the solution.
Using RTRIM like this it works:

SELECT * FROM tariffs WHERE '4321' LIKE RTRIM(prefix) + '%'

Your where clause:

Expand|Select|Wrap|Line Numbers
  1. WHERE prefix = '4321' OR prefix = '432' OR prefix = '43' OR prefix = '4'
  2.  
is similar to

Expand|Select|Wrap|Line Numbers
  1. WHERE PREFIX like '4%'

-- CK
Oct 22 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Mark McKay | last post: by
8 posts views Thread by Sridhar R | last post: by
8 posts views Thread by rbt | last post: by
11 posts views Thread by Paulo Eduardo | last post: by
6 posts views Thread by rhcarvalho | last post: by
10 posts views Thread by rdemyan via AccessMonster.com | last post: by
1 post views Thread by spacecoyote | last post: by
1 post views Thread by sowmya.rangineni | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.