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 |
|
ASP_DRUG_DEALER
Yak Posting Veteran
61 Posts |
Posted - 2004-07-14 : 15:48:15
|
| Hey all-I need to do a query and get all "Overhead" crap for a report, but there is no good way of doing this besides telling it what not to include (to many open-ended fields. It needs to be for a certian job\projectI can get one NOT LIKE BLA% but any more then that it does not work.SELECT E_NUM, E_ID, EO_ACCOUNT, EO_DEPT, EO_YEARMONTH, EO_UNITS, EO_DOLLARS, EO_C_ID, EO_B_ID, EO_O_ID, ER_C_ID, ER_B_ID, ER_O_ID, ER_CHANGEFROM E_MASTERWHERE (((ER_ACCOUNT NOT LIKE '501%') OR(ER_ACCOUNT NOT LIKE '509%') OR(ER_ACCOUNT NOT LIKE 'PROV%'))ANDER_J_ID = 'A0001') |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2004-07-14 : 15:50:55
|
| if it is '501ksajgf' then the where condition evals to(false or true or true) and falselooks like you got your ands and ors backwardstry:WHERE (((ER_ACCOUNT NOT LIKE '501%') AND(ER_ACCOUNT NOT LIKE '509%') AND(ER_ACCOUNT NOT LIKE 'PROV%'))ORER_J_ID = 'A0001')Corey |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-07-14 : 15:59:35
|
| remember: if A,B,C are boolean expressions, the opposite ofA and B and Cis(Not A) or (Not B) or (Not C)- Jeff |
 |
|
|
ASP_DRUG_DEALER
Yak Posting Veteran
61 Posts |
Posted - 2004-07-14 : 16:12:00
|
| whoa!Hang on just a second....So in my case if I wanted.(((ER_ACCOUNT LIKE '501%') OR(ER_ACCOUNT LIKE '509%') OR(ER_ACCOUNT LIKE 'PROV%'))ANDER_J_ID = 'A0001')But since I want the inverse for all but the ER_J_ID, I would do this..(((ER_ACCOUNT NOT LIKE '501%') AND(ER_ACCOUNT NOT LIKE '509%') AND(ER_ACCOUNT LIKE 'PROV%'))ANDER_J_ID = 'A0001')is this correct? |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-07-14 : 16:19:55
|
| i believe you are correct -- that should work.- Jeff |
 |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-07-14 : 23:45:19
|
| With your second example you don't need all the (((((()))))) AND is inclusive. Or is exclusive.MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
|
|
|
|
|