First delete some syntactical string sugar and some reorganization to almost be able to see what the query would look like:

Code:

SELECT DISTINCT aln.strain
FROM ALIGNMENT_TABLE aln
JOIN SET_TABLE s ON s.id=aln.setid
WHERE aln.ownerid='$ownerid'
AND s.deleted=$deleted
AND s.organismid=$organismid
ORDER BY
s.uploaded ASC
, aln.strain

So basically:
1. join ALIGNMENT_TABLE with SET_TABLE
2. Filter away based on ownerid, deleted and organismid
3. sort on s.uploaded and aln.strain
4. return a bunch of rows of aln.strain values

But since we don't know what type for example the column uploaded is we can't tell you if you are going to get the oldest records (if it's a datetime) or if it's an int that counts how many times a file has been uploaded, etc).

But always start by removing the syntactic sugar of the frontend programming language so that you actually see the query that is sent to the database (or better yet, run the query and capture it in the general query log for MySQL that way you will truly see what the query looks like, many problems like non initialized variables in where condition etc is found this way).