Well, to use the MIN function with non-aggregate columns, you need to group the operator. This is possible with a query that you have ... (EDIT based on more info)
SELECT MIN(v2.id) AS entryid, v1.id, v1.userid FROM views v1 INNER JOIN views v2 ON v1.userid = v2.userid GROUP BY v1.id, v1.userid
... however, if this is just a simple example, and you want to get more data with this query, it will quickly become an impossible solution.
What you think is necessary is a list of all user data in this view with a link to each line leading back to the first record that exists for the same user. The above query will give you what you want, but there are much simpler ways to determine the first entry for each user:
SELECT v1.id, v1.userid FROM views v1 ORDER BY v1.userid, v1.id
The first entry for each unique user is your entry point. I think I understand why you want to do it the way you indicated, and the first query I gave will be quite effective, but you will have to think about whether to use the order by clause to get the right answer ..
source share