I'm creating a script where I'm trying to select all the null values based on a specific field. The feature is joined with another feature, thus altering the title of fields to be FeatureName_FieldName. I want to keep these titles as I will be exporting the table and if I set qualified field names to False, the fields won't be able to be properly interpreted.
mayDevice = mayFeature+"_"+"DEVICE_ID"
whereClause = mayDevice "IS NULL"
arcpy.SelectLayerByAttribute_management(mayFeature, "NEW_SELECTION", whereClause)
I don't know how to include a variable in an "is null" expression.
Some suggestions Tiffanie:
print the query out to check what it looks like
do one manually and copy the result
check SQL reference for query expressions used in ArcGIS—ArcGIS Pro | ArcGIS Desktop there is an example there
Your whereClause as shown is missing a + sign and space before " IS NULL". When joining strings, I like to use .format as I find the code is a bit clearer. You might try something like:
mayDevice = "{}_DEVICE_ID".format(mayFeature)
whereClause = "{} IS NULL".format(mayDevice)