SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 don't want to retrieve 'unity'
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

gongxia649
So Suave

Azores
344 Posts

Posted - 09/19/2006 :  08:49:09  Show Profile  Visit gongxia649's Homepage  Reply with Quote
declare @TempAddressParsingTable table(
id_voter int null,
id_town varchar(10) null,
full_address varchar(200) null,
ad_num int null,
ad_str1 varchar(100) null,
ad_num_suffix_a varchar (10) null,
ad_num_suffix_b varchar (10) null,
ad_unit varchar(100) null)

insert @TempAddressParsingTable (ad_str1)
select 'apple UNITY RD' union all
select 'watermelon UNITY RD unit#32' union all
select 'currency UNITY RD unit# 99' union all
select 'marrakesh UNITY RD unit #32'


select * from @TempAddressParsingTable where ad_str1 like '%unit%'
select * from @TempAddressParsingTable where ad_str1 like '%unit%'
and ad_str1 not in (select ad_str1 from @TempAddressParsingTable where ad_str1 like '% unity %')



NULL
NULL NULL NULL apple UNITY RD NULL NULL NULL NULL
NULL NULL NULL watermelon UNITY RD unit#32 NULL NULL NULL NULL
NULL NULL NULL currency UNITY RD unit# 99 NULL NULL NULL NULL
NULL NULL NULL marrakesh UNITY RD unit #32 NULL NULL NULL



trying to write a code to display record sets where there are only "units". "apple unity rd" should not be shown.

Edited by - gongxia649 on 09/20/2006 21:37:33

SwePeso
Patron Saint of Lost Yaks

Sweden
29910 Posts

Posted - 09/19/2006 :  08:53:27  Show Profile  Visit SwePeso's Homepage  Reply with Quote
This maybe?

select * from @TempAddressParsingTable where patindex('%unit[^y]%', ad_str1) > 0



Peter Larsson
Helsingborg, Sweden
Go to Top of Page

harsh_athalye
Flowing Fount of Yak Knowledge

India
5509 Posts

Posted - 09/19/2006 :  08:55:02  Show Profile  Visit harsh_athalye's Homepage  Click to see harsh_athalye's MSN Messenger address  Send harsh_athalye a Yahoo! Message  Reply with Quote
select * from @TempAddressParsingTable where ad_str1 like '%unit[^y]%'


Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

jsmith8858
Dr. Cross Join

USA
7423 Posts

Posted - 09/19/2006 :  08:55:15  Show Profile  Visit jsmith8858's Homepage  Reply with Quote
or something more generic:

where ad_str1 like '%[^a-z]unit[^a-z]%'



- Jeff
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 09/19/2006 :  09:39:30  Show Profile  Reply with Quote
KIS_


declare @TempAddressParsingTable table( 
ad_str1 varchar(100) null)

insert @TempAddressParsingTable (ad_str1)
select 'apple UNITY RD' union all
select 'watermelon UNITY RD unit#32' union all
select 'currency UNITY RD unit# 99' union all
select 'marrakesh UNITY RD unit #32'

SELECT ad_str1 FROM @TempAddressParsingTable
WHERE ad_str1 LIKE '%unit %'
   OR ad_str1 LIKE '%unit#%'




Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000