Complicated delete query

From: Ragnar Midtskogen (ragnar_ng_at_optonline.net)
Date: 04/07/04


Date: Wed, 7 Apr 2004 12:46:14 -0400

Hello,

I have an application with a table used as an address book.
The table has fields for name, address, phone and company name.

Over the years the client has entered many incomplete records so he asked if
I would clean up the table.
What should be left in the table are records which have at least:
name and address
name and phone
company name and address
company name and phone

I think what I need to do is to select for deletion those records which only
has name or address or phone or company name, but the query below is the
only one I can come up with. It works, but it just seems needlessly
complicated.

DELETE *.*
FROM Alphadex
WHERE (
(
(((Alphadex.Last) Is Null) Or ((Alphadex.Last)=""))
AND
(((Alphadex.Address1) Is Null) Or ((Alphadex.Address1)=""))
AND
(((Alphadex.Address2) Is Null) Or ((Alphadex.Address2)=""))
AND
(((Alphadex.City) Is Null) Or ((Alphadex.City)=""))
AND
(((Alphadex.State) Is Null) Or ((Alphadex.State)=""))
AND
(((Alphadex.Zip) Is Null) Or ((Alphadex.Zip)=""))
AND
(((Alphadex.Phone) Is Null) Or ((Alphadex.Phone)=""))
AND
(((Alphadex.Company) Is Null) Or ((Alphadex.Company)=""))
)OR
(
(((Alphadex.First) Is Null) Or ((Alphadex.First)=""))
AND
(((Alphadex.Address1) Is Null) Or ((Alphadex.Address1)=""))
AND
(((Alphadex.Address2) Is Null) Or ((Alphadex.Address2)=""))
AND
(((Alphadex.City) Is Null) Or ((Alphadex.City)=""))
AND
(((Alphadex.State) Is Null) Or ((Alphadex.State)=""))
AND
(((Alphadex.Zip) Is Null) Or ((Alphadex.Zip)=""))
AND
(((Alphadex.Phone) Is Null) Or ((Alphadex.Phone)=""))
AND
(((Alphadex.Company) Is Null) Or ((Alphadex.Company)=""))
)
OR
(
(((Alphadex.First) Is Null) Or ((Alphadex.First)=""))
AND
(((Alphadex.Last) Is Null) Or ((Alphadex.Last)=""))
AND
(((Alphadex.Phone) Is Null) Or ((Alphadex.Phone)=""))
AND
(((Alphadex.Company) Is Null) Or ((Alphadex.Company)=""))
)
OR
(
(((Alphadex.First) Is Null) Or ((Alphadex.First)=""))
AND
(((Alphadex.Last) Is Null) Or ((Alphadex.Last)=""))
AND
(((Alphadex.Address1) Is Null) Or ((Alphadex.Address1)=""))
AND
(((Alphadex.Address2) Is Null) Or ((Alphadex.Address2)=""))
AND
(((Alphadex.City) Is Null) Or ((Alphadex.City)=""))
AND
(((Alphadex.State) Is Null) Or ((Alphadex.State)=""))
AND
(((Alphadex.Zip) Is Null) Or ((Alphadex.Zip)=""))
AND
(((Alphadex.Company) Is Null) Or ((Alphadex.Company)=""))
)
OR
(
(((Alphadex.First) Is Null) Or ((Alphadex.First)=""))
AND
(((Alphadex.Last) Is Null) Or ((Alphadex.Last)=""))
AND
(((Alphadex.Address1) Is Null) Or ((Alphadex.Address1)=""))
AND
(((Alphadex.Address2) Is Null) Or ((Alphadex.Address2)=""))
AND
(((Alphadex.City) Is Null) Or ((Alphadex.City)=""))
AND
(((Alphadex.State) Is Null) Or ((Alphadex.State)=""))
AND
(((Alphadex.Zip) Is Null) Or ((Alphadex.Zip)=""))
AND
(((Alphadex.Phone) Is Null) Or ((Alphadex.Phone)=""))
)
);

BTW, note that all fields allow zero length string, so I can not just check
for Null.

Any help would be appreciated.

Ragnar



Relevant Pages

  • Re: A97 - what would you do 99 times out of a hundred?
    ... completely (not unusual, BTW). ... >owner table - dog found table has a 0 instead of any other number in the ... >me as no different as a zero length string. ...
    (comp.databases.ms-access)
  • Re: Complicated delete query
    ... > FROM Alphadex ... > BTW, note that all fields allow zero length string, so I can not just ...
    (microsoft.public.access.queries)
  • Re: Adding functionality to ARM BASIC
    ... jgh@xxxxxxxxxxxxxxxxxx (Jonathan Graham Harston) wrote: ... VAL is specified to return either zero or the value of the decimal ... number in the string. ... BTW, you appear to have replied to the wrong post here. ...
    (comp.sys.acorn.programmer)
  • REPRESENT revisited
    ... Forth-94 has few floating point display functions [none in the ... If u is greater than zero the character string shall consist ... If u is zero the string shall consist of one digit representing ...
    (comp.lang.forth)
  • Re: Reproducing java calculations in UNIX
    ... quotient goes in x, also a double. ... is greater than zero) only the fractional part of the ... {fraction is 52 zero bits, ... is converted from string to floating point (string ...
    (comp.unix.shell)