If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > Deletion with LIKE

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-01-09, 08:09
laalaa laalaa is offline
Registered User
 
Join Date: Jul 2009
Posts: 1
Deletion with LIKE

Anyone knws how to amend this query doesnt check that HseName in Table t1 is not in Table t2 & t3 before deletion.

Table Details:
t1
HseName
------------
Grace House

t2 & t3
HseName
------------
Evergreen/London/Grace House

Code:
Delete a from t1 a left join t2 b on b.HseName LIKE '%'+a.HseName+'%'
left join t3 c on c.HseName LIKE '%'+a.HseName+'%'
where a.HseName='Grace House' and b.HseName is null and c.HseName is Null

Last edited by laalaa; 07-01-09 at 08:13.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On