Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Using "LIKE" for may results

Author  Topic 

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2008-05-15 : 06:43:07
Hi.
Can you tell my if i can use like for multiple results?
P.E. I want to find plate numbers that starts with p.e. IDK8883,DFF9999,GGG9043

The numbers don't follow a pattern so i cannot use "[]" and such.

Also i tried like'FFF3333' or like'TFR2345' etc but it does not work.

Any ideas?
Thanks.

raky
Aged Yak Warrior

767 Posts

Posted - 2008-05-15 : 06:50:51
quote:
Originally posted by sapator

Hi.
Can you tell my if i can use like for multiple results?
P.E. I want to find plate numbers that starts with p.e. IDK8883,DFF9999,GGG9043

The numbers don't follow a pattern so i cannot use "[]" and such.

Also i tried like'FFF3333' or like'TFR2345' etc but it does not work.

Any ideas?
Thanks.




declare @test table( names varchar(50))
insert into @test
select 'Ravikishore' union all
select 'Johnclifford' union all
select 'Ramesh'

select * from @test

suppose u want to find the names containing the word ravi or clifford
then

select * from @test where names like '%ravi%' or names like '%clifford%'

APPLY THE SAME CONCEPT IN YOUR PROBLEM ALSO
I.E.,
WHERE PLATE NUMBER LIKE '%FFF3333%' OR PLATE NUMBER LIKE '%TFR2345%'
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-05-15 : 06:54:06
[code]where col like '[A-Z][A-Z][A-Z][0-9][0-9][0-9][0-9]%'[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2008-05-15 : 07:20:06
Hi.
Yes or worked, i was just using it wrong. Thanks!

Also i cannot make harsh_athalye code to work.
I put carno like '[DFD5530][TYG9255]' but it does not return any results
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-05-15 : 08:13:06
Of course it wont work that way!

Why didn't you tried exactly the way I given you?

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2008-05-16 : 07:19:51
And will this do?
'[A-Z][A-Z][A-Z][0-9][0-9][0-9][0-9]%'
i just want specific car license numbers.
Thanks.
Go to Top of Page
   

- Advertisement -