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
 WHERE NOT
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

EricBHK
Starting Member

18 Posts

Posted - 08/17/2012 :  02:35:22  Show Profile  Reply with Quote
Hi !

I need to delete from an Access table those records that do NOT match my SQL search criteria.

I have the proper string for deleting in case criteria are met (see code below), but the invers situation simple won't work.

I have tried several thinsg such as :
WHERE NOT ... OR NOT
Keyword1 <> '" &ComboBox1.text & "'
WHERE EXISTS
... etc
but nothing seems to work.

Any suggestions ?


Thanks !




CopySql21 = "DELETE * FROM LiveSearch WHERE Keyword1 = '" & ComboBox1.Text & "' OR Keyword2 = '" & ComboBox1.Text & "' OR Keyword3 = '" & ComboBox1.Text & "' OR Keyword4 = '" & ComboBox1.Text & "' OR Keyword5 = '" & ComboBox1.Text & "' OR Keyword6 = '" & ComboBox1.Text & "' OR Keyword7 = '" & ComboBox1.Text & "' OR Keyword8 = '" & ComboBox1.Text & "' OR Keyword9 = '" & ComboBox1.Text & "' OR Keyword10 = '" & ComboBox1.Text & "' "

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3328 Posts

Posted - 08/17/2012 :  03:57:00  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
When you change to a not yoou also need to change or to and.
Alternatively get the PKs from your original query and use those for the delete.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

EricBHK
Starting Member

18 Posts

Posted - 08/17/2012 :  04:12:11  Show Profile  Reply with Quote
Hi nigelrivett,

Thanks for your answer. Unfortunatly, changing OR into AND was already one of the possibilities I examinded (see code below) and that failed.


CopySql21 = "DELETE * FROM LiveSearch WHERE Keyword1 <> '" & ComboBox1.Text & "' AND Keyword2 <> '" & ComboBox1.Text & "' AND Keyword3 <> '" & ComboBox1.Text & "' AND Keyword4 <> '" & ComboBox1.Text & "' AND Keyword5 <> '" & ComboBox1.Text & "' AND Keyword6 <> '" & ComboBox1.Text & "' AND Keyword7 <> '" & ComboBox1.Text & "' AND Keyword8 <> '" & ComboBox1.Text & "' AND Keyword9 <> '" & ComboBox1.Text & "' AND Keyword10 <> '" & ComboBox1.Text & "' "
Go to Top of Page

EricBHK
Starting Member

18 Posts

Posted - 08/17/2012 :  05:11:54  Show Profile  Reply with Quote
To the specific nature of this problem : I discovered that the SQL search is actually starting but that it is stopped (or at least pauzed) after the first row in my Access.datatable (given that this first row does not contain the value as selected in ComBoBox1.text !!!

So the real question is not so much related to the SQL script but rather on how to make the search persist through the entire Access.datatable ?????


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.05 seconds. Powered By: Snitz Forums 2000