"derived tables must have an alias"
That error means that when you use a subquery in the FROM
clause, it's called a derived table and you must declare an alias for that.
Here's a simpler form of your query that should work:
SELECT events.* FROM events
JOIN (SELECT DISTINCT event_start_date FROM events
WHERE event_start_date >= '2014-05-02'
ORDER BY event_start_date LIMIT 3) AS d USING (event_start_date)
I provided an alias for the derived table where you see AS d
. It doesn't matter what you choose as the alias, it just has to have one.
"Unknown column 'rownum' in 'where clause'"
ROWNUM
is an Oracle-specific feature that automatically provides an imaginary column to every result set, with an integer corresponding to the row number of that result set. But this is not standard SQL, and MySQL doesn't support it.
So I removed the reference to the implicit ROWNUM
column, and replaced it with a LIMIT
clause.