A simple question I've been asked: Is it possible to merge two UPDATE queries, each on different WHERE conditions, into a single query? For example, is it possible to merge the following two UPDATE statements into one? mysql> UPDATE film SET rental_duration=rental_duration+1 WHERE rating = 'G'; Query OK, 178 rows affected (0.01 sec) mysql> UPDATE […]
A few days ago I published SQL: selecting top N records per group. It just dawned on me that the very same query solved another type of problem I was having a couple years ago. BTW, for reference, Baron Schwartz posted this 4 years ago. There are very interesting approaches in text and in comments. […]
A while back I presented(*) an SQL trick to present with non-aggregated column on a GROUP BY query, without use of subquery or derived tables. Based on a similar concept, combined with string walking, I now present a query which selects top-n records for each group, ordered by some condition. It will require no subqueries. […]
I'm very pleased and humbled to announce that my submission to the upcoming O'Reilly MySQL Conference, April 2011, has been accepted. I will present a 45 minute session titled openark-kit: MySQL utilities for everyday use. In this session, I will present some of the tools in the openark kit. We'll discuss some limitations of the […]