Link to home
Start Free TrialLog in
Avatar of APD Toronto
APD TorontoFlag for Canada

asked on

SQL AND

Hi Experts,

I have the following query
SELECT tblPayers.fldPayerID, tblPayers.fldFName, tblPayers.fldLName, [fldArchived]*(-1) AS archived
FROM tblPayers
WHERE (((tblPayers.fldFName)<>"") AND ((tblPayers.fldLName)<>""))
ORDER BY tblPayers.fldPayerID;

Open in new window


My code is to exclude all records where both fName and lName are blank, but do include if either one contains something, but this query returns:

fldPayerID      fldFName      fldLName      archived
3      Tim      Cooper      0
6      A      N      1

Where, without my WHERE, I get

fldPayerID      fldFName      fldLName      archived
1      DEPOSIT            0
2      N/A            0
3      Tim      Cooper      0
4      paycheque            0
5      Envelope to Tim            0
6      A      N      1

In this case, I expect to get all 6 records with and without the WHERE.

What am I doing wrong?
SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of APD Toronto

ASKER

Scott, same results.

Aneesh, syntax error.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This works, but why & ""<>"" and not <> ""  ?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
that is to force the null values to a zero length string