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.
| Author |
Topic |
|
Looper
Yak Posting Veteran
68 Posts |
Posted - 2009-06-23 : 10:59:56
|
The following query is deleting ALL from the table instead of meeting the criteria in the where clause, can someone adviseDELETE esmFROM EmpSMed esmINNER JOIN empt e ON e.Id = esm.EmptIdINNER JOIN EmpSubPay esp ON esp.EmptId = e.IdWHERE SUBSTRING(esp.Full,4,1) <> 'A' OR SUBSTRING(esp.Full,4,1) <> 'B' OR SUBSTRING(esp.Full,4,1) <> 'C' OR emp.Job <> 'M And D'Basically if there are rows in table EmpSMed and they do not have A,B or C in 4th character of field Full or field Job is not M and D then delete from table EmpSMed. currently the above query is removing everything from the table. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-06-23 : 11:08:46
|
the checking of esp.Full should be a AND condition not ORor you can write it this wayWHERE SUBSTRING(esp.Full,4,1) not in ('A', 'B', 'C' )OR emp.Job <> 'M And D' KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-06-23 : 11:10:05
|
NOT OR NOT is always true!Because when esp.full,4,1 is B then SUBSTRING(esp.Full,4,1) <> 'A' is truewhen esp.full,4,1 is A then SUBSTRING(esp.Full,4,1) <> 'B' is true and so on...I believe you mean AND.What is this? OR emp.Job <> 'M And D' ??Webfred No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-06-23 : 11:10:44
|
again tooooooooooooo late  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Looper
Yak Posting Veteran
68 Posts |
Posted - 2009-06-23 : 11:22:59
|
| Thanks that worked. |
 |
|
|
|
|
|
|
|