Question: Hey! i want to know the best solution for my problem.
I have a signature generator <http://www.anitard.org/siggen/siggen_stripes/> where people can upload their own images for the signature. The problem is that my storage will get full pretty fast if i dont somehow have a script that deletes the images when they are done with the signature.

What is the best solution for this?

Answer: 
I don't know why MySQL allows you to do that, but normally in SQL the following query is not valid

```
SELECT cmt_id, thread_id, cmt_text, MIN(cmt_id) FROM comments 
GROUP BY thread_id;

```

You shouldn't be able to specify a SELECT column if it is not

1. A `GROUP BY` column
2. An aggregate function (e.g. `MIN`, `MAX`, `COUNT`, `SUM`...)

In your case I would use this select

```
SELECT cmt_id, thread_id, cmt_text FROM comments INNER JOIN (
  SELECT MAX(cmt_id) AS cmt_id FROM comments 
  GROUP BY thread_id
) a ON a.cmt_id = comments.cmt_id 

```
```
SELECT *
FROM comments
     INNER JOIN (
       SELECT cmt_id = MIN(cmt_id), thread_id
       FROM comments
       GROUP BY thread_id
     ) cmin ON cmin.cmt_id = comments.cmt_id

```