0

I am trying to come up with a SQL statement that will select the data based on multiple criteria and using multiple fields, but it is not returning the correct results back.

Example: Depth < 1 OR Depth > 7 OR Offset < 9 OR HSDV > 4 OR VSDV > 12

I want all points that meet just one of these criteria to be selected.

  • Are you getting no results at all or incorrect results? – lambertj Aug 29 '18 at 20:19
  • usually just the first part of the statement is retuned 'Depth < 1' – M.Welch Aug 29 '18 at 20:22
  • It would help if you included all of the relevant SQL statement in the question. – Dan C Aug 29 '18 at 20:50
  • How are you executing the query? Using Select by Attributes? – BERA Aug 30 '18 at 11:22
1

You can make it with the following query:

SELECT *
FROM [table_name]
WHERE (Depth < 1 OR Depth > 7) OR Offset < 9 OR (HSDV > 4 OR VSDV > 12)

Moreover, I am thinking that this part HSDV > 4 OR VSDV > 12 of your query does not make much sense (as well as HSDV < 4 OR VSDV < 12) because HSDV > 4 already includes VSDV > 12 (alternatively VSDV < 12 already includes HSDV < 4). You may rather use HSDV < 4 OR VSDV > 12 if you want values less then 4 and more then 12, otherwise you can use HSDV > 4 OR VSDV < 12 to get values in the range between 4 and 12.

Tutorials on a topic SQL Operators (AND and OR) and their combination could be found here:

  • I will give this a try – M.Welch Aug 29 '18 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.