G
Guest
Hi
I'm trying to return a record that another referres to and have come to the follwing sql query
SELECT TOP
IIF(refid = 0
(SELECT TOP 1 id FROM forum_posts ORDER BY id DESC)
(SELECT id FROM forum_posts WHERE id = t1.refid
) AS realI
FROM forum_posts t
ORDER BY id DES
Unfortunately, I want more than just the id column, I also want 'header', 'datecreated' and 'usr'. How do I go about it? THe only solution so far is to create an IIF statement for each column and just replace the criteria id in each. Is there another way?
I'm trying to return a record that another referres to and have come to the follwing sql query
SELECT TOP
IIF(refid = 0
(SELECT TOP 1 id FROM forum_posts ORDER BY id DESC)
(SELECT id FROM forum_posts WHERE id = t1.refid
) AS realI
FROM forum_posts t
ORDER BY id DES
Unfortunately, I want more than just the id column, I also want 'header', 'datecreated' and 'usr'. How do I go about it? THe only solution so far is to create an IIF statement for each column and just replace the criteria id in each. Is there another way?