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.

Taras
35.8k5 gold badges77 silver badges152 bronze badges
asked Aug 29, 2018 at 20:16
5
  • Are you getting no results at all or incorrect results? Commented Aug 29, 2018 at 20:19
  • usually just the first part of the statement is retuned 'Depth < 1' Commented Aug 29, 2018 at 20:22
  • It would help if you included all of the relevant SQL statement in the question. Commented Aug 29, 2018 at 20:50
  • How are you executing the query? Using Select by Attributes? Commented Aug 30, 2018 at 11:22
  • Please, do not forget about "What should I do when someone answers my question?" Commented Jul 6, 2021 at 7:20

1 Answer 1

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:

answered Aug 29, 2018 at 20:39
1
  • I will give this a try Commented Aug 29, 2018 at 21:23

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.