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 2000 Forums
 Transact-SQL (2000)
 fetching the right data

Author  Topic 

samwise
Starting Member

7 Posts

Posted - 2005-10-26 : 09:45:32
Hi,

How do i write a query in which i want to retrieve all the phone numbers beginning with 20 except for 201 (i need 200,202,203 etc')

Sorry if the question sounds dumb but i can't find the right syntax.

Thanks,

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-10-26 : 09:56:02
where phoneNum like '20[^1]%'

Go with the flow & have fun! Else fight the flow
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-26 : 09:57:44

Select columns from yourTable where phoneNo like '20%' and phoneNo <>201

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

samwise
Starting Member

7 Posts

Posted - 2005-10-26 : 11:30:12
didn't work.

had to use REGEXP '^20[^1](1)*'

thanks anyway
quote:
Originally posted by spirit1

where phoneNum like '20[^1]%'

Go with the flow & have fun! Else fight the flow

Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-10-26 : 11:44:15
what do you mean it didn't work?
this select 10250 - 10259, without selecting 10251. isn't that what you wanted??

use northwind
select * from orders
where orderid like '1025[^1]%'



Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -