For the class that I'm taking, I need to identify if one region of the country has more instances than the others.
The regions are provided in a separate document that breaks the states down into groups of 5+ each.
I'm pretty sure that I could include every state for each region in the WHERE clause, listing each state individually.
I'm trying to figure out how to avoid having 10 or 15 different OR operators in the same sql statement.
I'm using MySQL 5.5.62 running on a VM with ubuntu0.14.04.1.
I'm very much a newbie, and I'm not very proficient at scripts.
SQL has a very nice operator that can be used in place of multiple "OR" tests when a single column is compared. It's the "IN" operator. Like so:
However, from the sound of it, you're really looking to collate statistics by regions and that would require multiple SQL queries. So the use of a region table joined with the primary table, as others have described here, would be simpler.
Science is the process of replacing what we "know" with what is TRUE. Politics, alas, often prefers to be the opposite.
I contacted my instructor about the permissibility of creating another table, he says that "it's outside the scope of the assignment".
He also said that he is looking for the use of multiple OR multiple times in the WHERE clause.
I have completed the assignment, I used OR multiple times in the WHERE clause for each region.
I suppose your instructor hopes to teach you how to use the OR operator in SQL, but in real life it would be horrifying if you actually had to do what you just did. I guess it's a good thing I didn't go into teaching...