• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 798
  • Last Modified:

SQL - "except" statements

Hi Experts

Some difficulty finding info on except arguments in SQL.  This query works up to line 3. Adding line 4 causes a syntax error . Some resource at EE says there is no "except" in SQL??? Can this query be written another way?

Many thanks

Peter
SQL = SQL & " select [PD_PatID], [PD_FName], [PD_LName]"
        SQL = SQL & " from PATIENT_DETAILS"
        SQL = SQL & " where [PD_Diabetic] = True"
        SQL = SQL & " except where [PD_Addr1] LIKE '*Tricare*'"

Open in new window

0
peterdarazs
Asked:
peterdarazs
1 Solution
 
Missus Miss_SellaneusCommented:
Try changing line 4 to:
SQL = SQL & " AND NOT [PD_Addr1] LIKE '*Tricare*'"
0
 
peterdarazsAuthor Commented:
OK,  that should do it. Many thanks and enjoy the day further.

Peter.
0
 
fesnyngCommented:
Nice job Miss_Sellaneus.

There is an addition concern with your statement:

LIKE '*Tricare*'  is the same as =  '*Tricare*'

I suspect that you intended for the astericks ( * )  to be wildcard characters.  For SQL Server, the wildcard character would be %.  If you, however, you intended for the * characters to be there, then you would be better off using = (equals) instead of LIKE.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now