Thank's for your answer. I applied your code to my work.
but it doesn't works good.The first raster is added correctly,but it is no one of the selected raster in the table.
I think the code tries to add all the files.
And then, the code show this message:
Runtime error
Traceback (most recent call last):
File "", line 20, in
NameError: name 'result' is not defined
Mi code is this:
#get the mxd you're in
mxd = arcpy.mapping.MapDocument("CURRENT")
#get the dataframe
df = mxd.activeDataFrame
#select the records via your query
arcpy.SelectLayerByAttribute_management("CATALUNA_2013", "NEW_SELECTION")
#create a cursor to go through those records
rows = arcpy.SearchCursor("CATALUNA_2013")
#go through the records
for row in rows:
#get the path
tablePath = row.getValue("FILENAME")
#set up the new raster layer
rasterLayer = arcpy.MakeRasterLayer_management(tablePath, row.NAME)
#get the output from the in memory layer
addLayer = result.getOutput(0)
#insert into the data frame
arcpy.mapping.AddLayer(df, addLayer, "AUTO_ARRANGE")
del rows