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– lambertj2018年08月29日 20:19:22 +00:00Commented Aug 29, 2018 at 20:19
-
usually just the first part of the statement is retuned 'Depth < 1'M.Welch– M.Welch2018年08月29日 20:22:23 +00:00Commented Aug 29, 2018 at 20:22
-
It would help if you included all of the relevant SQL statement in the question.Dan C– Dan C2018年08月29日 20:50:49 +00:00Commented Aug 29, 2018 at 20:50
-
How are you executing the query? Using Select by Attributes?Bera– Bera2018年08月30日 11:22:40 +00:00Commented Aug 30, 2018 at 11:22
-
Please, do not forget about "What should I do when someone answers my question?"Taras– Taras ♦2021年07月06日 07:20:57 +00:00Commented Jul 6, 2021 at 7:20
1 Answer 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 tryM.Welch– M.Welch2018年08月29日 21:23:34 +00:00Commented Aug 29, 2018 at 21:23