On Mon, 10 Nov 2008 20:02:39 -0600, Andrew <[EMAIL PROTECTED]> wrote:
>sql = 'SELECT id FROM master'
>rows=list(cursor.execute(sql))
>for id in rows:
>       sql = 'SELECT COUNT(code) FROM companies WHERE code="%s"' % id[0]
>       result = list(cursor.execute(sql))
>       print "Code=%s, number=%s" % (id[0],result[0][0])
>Notice the extra [0] index on the "result" 
>
>In English:
>Item zero of the tuple that is item zero of result

Thanks, it worked. But why does "id[0]" return the value of the first
(and only) column as I expected it, while I need to use "result[0]
[0]" to access the first column?
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to