This is a working code made using exporting the script from ModelBuilder.
import arcpy # Local variables: Links_Final = "Links_Final" condition = "\"RR1\"= 777 OR \"RR2\"=777 OR \"RR3\"=777 OR \"RR4\"=777" # Process: Select Layer By Attribute arcpy.SelectLayerByAttribute_management(Links_Final, "NEW_SELECTION", condition)
However, the I want the value 777 in the condition to be taken from the user. So I added this code.
value = int(arcpy.GetParameterAsText(0)) condition = "\"RR1\"= value OR \"RR2\"= value OR \"RR3\"= value OR \"RR4\"= value"
Now the code throws an error saying, Invalid expression Failed to execute (SelectLayerByAttribute)
I have also followed the thread https://stackoverflow.com/questions/32483187/trying-to-create-a-simple-select-by-attribute-script-based-on-an-input but that does not work either.
Note: My data type on the field is long integer and the data type taken from the user (as specified while creating the script) was long (as I could not find int type there)