Cannot step through asynchronous iterator manually

Gregory Ewing greg.ewing at canterbury.ac.nz
Sat Jan 30 17:50:56 EST 2016


Michael Torrie wrote:
> I'm not sure how SQLite handles it, or even what the SQL spec says, but
> I know in MySQL you could do something like this:
> 
> SELECT count(id) as row_count,`tablename`.* FROM `tablename` WHERE condition

I don't think that's strictly valid SQL. I know of at least
one SQL implementation that complains if you have fields in
an aggregate query that aren't either in an aggregate function
or listed in the GROUP BY clause.

To make it valid you would have to wrap LAST() around all
of the other fields. (Probably individually -- I doubt whether
LAST(tablename.*) would be accepted.)

Which seems like a lot of trouble to go to just to tell
whether you have a unique result.

Also it's asking the DB to perform more work than you really
need. It has to run the whole query before returning any
results, whereas doing it yourself you can give up after
reading the second result if there is one.

-- 
Greg



More information about the Python-list mailing list