Hi,
Passt doch so, oder?
was sagt EXPLAIN SELECT ...?
Hab den SQL etwas angepasst, war ein Fehler drin:
EXPLAIN
SELECT
posts.id,
posts.posx,
posts.posy,
posts.topic,
posts.time,
users.username,
IF(postviews.time IS NOT NULL, postviews.time, 0) as viewed
FROM
posts
LEFT JOIN
users
ON posts.username=users.username
LEFT JOIN
postviews
ON posts.id=postviews.postid
AND postviews.username='bechte'
WHERE
posts.boardid=1
AND posts.threadid=1
ORDER BY
posts.posy ASC,
posts.time ASC;
EXPLAIN sagt:
+-----------+--------+----------------------+--------+---------+--------+------+-------+
| table | type | possible_keys | key | key_len | ref | rows | Extra |
+-----------+--------+----------------------+--------+---------+--------+------+-------+
| posts | system | BOARDSORT,THERADSORT | [NULL] | [NULL] | [NULL] | 1 | |
| users | system | PRIMARY | [NULL] | [NULL] | [NULL] | 1 | |
| postviews | system | PRIMARY | [NULL] | [NULL] | [NULL] | 1 | |
+-----------+--------+----------------------+--------+---------+--------+------+-------+
Gruss
Stefan