I am using ArcGIS Pro 2.4.3, and just running this script through IDLE for ArcGIS Pro.
I am having some difficulty getting a standard expression in Python to return what I need. I have created a simple query to try and run...if I can get this to work then I will insert this into my main program with added functions.
When I run the script it only returns 16 records (i.e. records for only for variable Q1_A). I'm trying to get it to return 18 records (which would include Q1_B).
import arcpy
Q1_A = "CHARLES HAYS"
Q1_B = "SMIT CLYDE"
fc1 = (r"F:\ArcGIS_Pro_Projects\AIS\AIS_Data\AIS_Data.gdb\TEST_AIS_Data")
expression1 = ("Vessel_Name = '" + str(Q1_A) + "'" or "Vessel_Name = '" + str(Q1_B) + "'")
print ("")
print (expression1)
SelectResult = arcpy.SelectLayerByAttribute_management((fc1), "NEW_SELECTION", (expression1))
CountTotal = arcpy.GetCount_management((fc1))
CountResult = arcpy.GetCount_management(SelectResult)
print ("")
print (str(CountResult) + " Of " + str(CountTotal) + " Records Selected")
arcpy.SelectLayerByAttribute_management((fc1), "CLEAR_SELECTION")
Hardcoding it (as per what is commented out) works exactly as I need it to work, and returns 18 records.
If I use an "and" instead of an "or" it returns 2 records (only for Q1_B). Logic tells me that using an "or" it should select 18 records (i.e. for both Q1_A and Q1_B).
The print statement (e.g. print (expression1)) also only prints the variable Q1_A.
What am I doing wrong here? How do I get the variable "expression1" to read the entire string? I know I'm missing something, but for the life of me I just can't see it...and I have been spinning my wheels on this all afternoon.
Suggestions?
Thank you