insert into #variables.tableprefix#forums(id,name,description,readonly,active,conferenceidfk,attachments) values(, , , , , , ) delete from #variables.tableprefix#forums where id = delete from #variables.tableprefix#subscriptions where forumidfk = select id, name, description, readonly, active, conferenceidfk, attachments from #variables.tableprefix#forums where id = select #variables.tableprefix#forums.id, #variables.tableprefix#forums.name, #variables.tableprefix#forums.description, #variables.tableprefix#forums.readonly, #variables.tableprefix#forums.attachments, #variables.tableprefix#forums.active, #variables.tableprefix#forums.conferenceidfk, #variables.tableprefix#conferences.name as conference, max(#variables.tableprefix#messages.posted) as lastpost, count(#variables.tableprefix#messages.id) as messagecount, ( select threadidfk from #variables.tableprefix#messages m where m.posted = (SELECT max(mm.posted) as lastpost from (#variables.tableprefix#forums f left join #variables.tableprefix#threads t ON f.id = t.forumidfk) left JOIN #variables.tableprefix#messages mm ON t.id = mm.threadidfk where f.id = #variables.tableprefix#forums.id and #variables.tableprefix#conferences.id = ) ) as threadidfk from ((#variables.tableprefix#forums inner join #variables.tableprefix#conferences on #variables.tableprefix#forums.conferenceidfk = #variables.tableprefix#conferences.id) left join #variables.tableprefix#threads on #variables.tableprefix#forums.id = #variables.tableprefix#threads.forumidfk) left join #variables.tableprefix#messages on #variables.tableprefix#threads.id = #variables.tableprefix#messages.threadidfk where 1=1 and #variables.tableprefix#forums.active = 1 and #variables.tableprefix#forums.conferenceidfk = group by #variables.tableprefix#forums.id, #variables.tableprefix#forums.name, #variables.tableprefix#forums.description, #variables.tableprefix#forums.readonly, #variables.tableprefix#forums.attachments, #variables.tableprefix#forums.active, #variables.tableprefix#forums.conferenceidfk, #variables.tableprefix#conferences.name, #variables.tableprefix#conferences.id order by #variables.tableprefix#forums.name select useridfk from #variables.tableprefix#messages where threadidfk = and posted = update #variables.tableprefix#forums set name = , description = , readonly = , active = , attachments = , conferenceidfk = where id = select id, name, description from #variables.tableprefix#forums where active = 1 and ( (name like or description like '%#aTerms[x]#%') #joiner# name like or description like '%#arguments.searchTerms#%' )