M
Martin
I'm trying to sort the following query by 'latest_id', but the outcome
is wrong.
SELECT id,
(SELECT Max(id) FROM forum_posts WHERE id = t1.id OR refid = t1.id) AS
latest_id
FROM forum_posts t1
WHERE catid = 1
AND refid = 0
ORDER BY 2 DESC
the result is:
id latest_id
35 39
33 34
31 40
while it should be:
id latest_id
31 40
35 39
33 34
How come? And is there another way except sorting by column id? I've
tried the following without success (generates errors):
ORDER BY (SELECT Max(id) FROM forum_posts WHERE id = t1.id OR refid =
t1.id) DESC
and
ORDER BY latest_id DESC
Thanks for help!
/Martin
is wrong.
SELECT id,
(SELECT Max(id) FROM forum_posts WHERE id = t1.id OR refid = t1.id) AS
latest_id
FROM forum_posts t1
WHERE catid = 1
AND refid = 0
ORDER BY 2 DESC
the result is:
id latest_id
35 39
33 34
31 40
while it should be:
id latest_id
31 40
35 39
33 34
How come? And is there another way except sorting by column id? I've
tried the following without success (generates errors):
ORDER BY (SELECT Max(id) FROM forum_posts WHERE id = t1.id OR refid =
t1.id) DESC
and
ORDER BY latest_id DESC
Thanks for help!
/Martin