This is what I'm trying to do:
From the targetLayer I pick the value for the PSS_ID attribute, look for the same value in my in_table and retrieve the values for the fields 2 and 3 (row2[1] and row2[2]).
I managed to do it with shp-files (and the ID was a string):
expression<SPAN class="operator token">=</SPAN><SPAN class="string token">'\"UPI\"=\''</SPAN><SPAN class="operator token">+</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="operator token">+</SPAN><SPAN class="string token">'\''</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
but now I have to apply it on a gdb and I struggle to find the right way to put the sql statement ("expression").
<SPAN class="comment token">#walk through targetLayer, retrieve the PSS_ID</SPAN>
cursor <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>SearchCursor<SPAN class="punctuation token">(</SPAN>targetLayer<SPAN class="punctuation token">,</SPAN> join1<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> cursor<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#prints the PSS_ID</SPAN>
<SPAN class="comment token">#walk through joinTable, look for rows that have the same UPI as the targetLayer and retrieve UPI [0], Taxonomy [1] and FAO_CLASSI [2]</SPAN>
Tax_con<SPAN class="operator token">=</SPAN><SPAN class="string token">""</SPAN> <SPAN class="comment token">#Variable for adding up the values</SPAN>
in_table<SPAN class="operator token">=</SPAN>outputJoin <SPAN class="comment token">#Variable in which table to look for the values</SPAN>
field_name1<SPAN class="operator token">=</SPAN>join1 <SPAN class="comment token">#First field name</SPAN>
field_name2<SPAN class="operator token">=</SPAN>join2 <SPAN class="comment token">#Second field name</SPAN>
field_name3<SPAN class="operator token">=</SPAN>join3 <SPAN class="comment token">#Third field name</SPAN>
expression<SPAN class="operator token">=</SPAN> <SPAN class="string token">'\"'</SPAN><SPAN class="operator token">+</SPAN>join1<SPAN class="operator token">+</SPAN><SPAN class="string token">'='</SPAN><SPAN class="operator token">+</SPAN>str<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="operator token">+</SPAN><SPAN class="string token">'\"'</SPAN> <SPAN class="comment token">#SQL expression to look for the right row</SPAN>
<SPAN class="keyword token">print</SPAN> expression <SPAN class="comment token">#prints the expression</SPAN>
<SPAN class="comment token">#SearchCursor looking for the values corresponding to the requested UPI</SPAN>
cursor2 <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>SearchCursor<SPAN class="punctuation token">(</SPAN>in_table<SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN>field_name1<SPAN class="punctuation token">,</SPAN> field_name2<SPAN class="punctuation token">,</SPAN> field_name3<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN>expression<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> row2 <SPAN class="keyword token">in</SPAN> cursor2<SPAN class="punctuation token">:</SPAN>
row_text<SPAN class="operator token">=</SPAN> row2<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="operator token">+</SPAN> row2<SPAN class="punctuation token">[</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
I looked for example here Specifying a query in Python—ArcPy Get Started | ArcGIS for Desktop and here ArcGIS Desktop and here How To: Use Python to determine the SQL syntax for a WHERE clause depending on the workspace type but I always get the same response: Invalid SQL statement 
I also tried to put the expression straight to the where_clause position but it didn't seem to make any difference.
Here are the version that I tried (output from "print expression"):
"PSS_ID=13.0"
PSS_ID=13.0
[PSS_ID]=13.0
'"PSS_ID"=13.0'
"'PSS_ID'=13.0"
'PSS_ID'=13.0
I tried also the triple quotation marks inside da.SearchCursor like suggested here Specifying a query in Python—ArcPy Get Started | ArcGIS for Desktop (although I don't see why triple quotation marks should be easier to read and to understand
😞
arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>SearchCursor<SPAN class="punctuation token">(</SPAN>in_table<SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN>field_name1<SPAN class="punctuation token">,</SPAN> field_name2<SPAN class="punctuation token">,</SPAN> field_name3<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">""""PSS_ID"=13.0"""</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
It would be great if someone could assist me on this - I've already spent so much time on looking for the right answer 