Results 1 to 12 of 12

Thread: Sql Query Problem

  1. #1

    Thread Starter
    Frenzied Member mxnmx's Avatar
    Join Date
    Dec 2001
    Location
    I'm back...now!!!
    Posts
    1,396

    Sql Query Problem

    Hey Again
    I have this query now:
    Delete * FROM final where Vaccination <> 'BCG' or Vaccination <> 'BCG & POLIO' or Vaccination <> 'Booster DPT & Polio' or Vaccination <> 'Booster DT & Polio' or vaccination<>'Booster Hepatitis B' or vaccination <>'CHICKENPOX VACCINE' or vaccination <>'DPT' or vaccination<>'DPT 1 & POLIO' or vaccination<>'DPT 2 & POLIO' or vaccination<>'DPT 3 & POLIO' or vaccination<>'DT & POLIO 1' or vaccination<>'DT & POLIO 2' or or vaccination<>'DT & POLIO 3' or vaccination<>'H.I.B.1' or vaccination<>'H.I.B.2' or vaccination<>'H.I.B.3' or vaccination <>'H.I.B.Booster' or vaccination<>'Hepatitis A 1' or vaccination<>'Hepatitis A 2' or vaccination<>'Hepatitis A 3' or vaccination<>'Hepatitis B 1' or vaccination<>'Hepatitis B 2' or vaccination<>'Hepatitis B 3' or vaccination<> 'Hepatitis B Booster' or vaccination<>'M.M.R.' or vaccination<>'Measles' or vaccination<>'Meningococal A+C' or vaccination<>'Polio' or vaccination<>'Rabies Vaccine' or vaccination<>'T.T' or vaccination<>'Typhi' or vaccination <>'Yellow Fever'
    When I run this query it deletes everything form the field Vaccination.
    Can't Remember Birthdays or Important Dates- Never Miss any Important Date(s)

  2. #2
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385
    mxnmx,

    Do you mean it deletes everything form the table Final, It can not possibly delete information from fields, only Update queries can do that.

    If it deletes all records try using and instead of or.

  3. #3

    Thread Starter
    Frenzied Member mxnmx's Avatar
    Join Date
    Dec 2001
    Location
    I'm back...now!!!
    Posts
    1,396
    No it does not delete everything form the Table but everything in the field Vaccination.
    Can't Remember Birthdays or Important Dates- Never Miss any Important Date(s)

  4. #4
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385
    mxnmx,

    What database are you using.


    A delete query can not and will not delete information from fields. Delete is a row operator not a column operator.

  5. #5
    Hyperactive Member
    Join Date
    Mar 2001
    Location
    Calgary
    Posts
    273
    What about if you change the comparison <> operator. Do you want to omit all these fields. Also you can use words "is not iqual" please organize your query fields
    mannyso

  6. #6

    Thread Starter
    Frenzied Member mxnmx's Avatar
    Join Date
    Dec 2001
    Location
    I'm back...now!!!
    Posts
    1,396
    I'm using Access XP.
    Can't Remember Birthdays or Important Dates- Never Miss any Important Date(s)

  7. #7

    Thread Starter
    Frenzied Member mxnmx's Avatar
    Join Date
    Dec 2001
    Location
    I'm back...now!!!
    Posts
    1,396
    Thanks randem
    I exactly know what you are saying and thats what I expected and thats why I posted it here. My Table has about 42,000 records. So I dont really know why is it happening...
    Can't Remember Birthdays or Important Dates- Never Miss any Important Date(s)

  8. #8
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385
    mxnmx,

    If you can convert the database to a prior version (Access 2000), I can take a look. It might be Access XP or something on your PC. But there is no way that what you described supposed to happen.
    Last edited by randem; Jan 11th, 2003 at 05:38 PM.

  9. #9

    Thread Starter
    Frenzied Member mxnmx's Avatar
    Join Date
    Dec 2001
    Location
    I'm back...now!!!
    Posts
    1,396
    Ok I have attached the database along with the 2 queries and that table. Please have a look
    Attached Files Attached Files
    Can't Remember Birthdays or Important Dates- Never Miss any Important Date(s)

  10. #10
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385
    mxnmx,


    I modified the db you posted to do exactly what you wanted. Your perception of what was happening was the issue. The query was not deleting the information in the fields, it was deleting all the records and leaving the ones that had nothing in the field Vaccinations.

    I changed your or's to and's and this works fine, except is does not do exactly what you want so I modified your other query to give you exactly what you wanted.


    See Attached
    Last edited by randem; Jan 11th, 2003 at 06:30 PM.

  11. #11
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385
    mxnmx,

    Sorry that post got away!


    DELETE FINAL.VACCINATION, *
    FROM FINAL
    WHERE (((FINAL.VACCINATION) Is Null));

    Is what you are looking for.

  12. #12

    Thread Starter
    Frenzied Member mxnmx's Avatar
    Join Date
    Dec 2001
    Location
    I'm back...now!!!
    Posts
    1,396
    Thanks so much randem....that rocks!!!
    Can't Remember Birthdays or Important Dates- Never Miss any Important Date(s)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width