<cfquery name="GetForums" datasource="#application.MainDB#">
select a.name as category_name, a.Role_Moderate,
b.unique_ID, b.title, b.description, b.Show_Description, b.Last_Post_Date, b.Last_Post_UserName,b.Last_Post_ID, b.category_ID,
b.topics, b.posts, b.locked,
<cfif session.forumStruct.Forum_User_ID is 0>null as lastVisit
<cfelse>(select max(Visit_Date) from Gerobase_Forum_TopicUserVisit c where c.user_ID = #session.forumStruct.Forum_User_ID# and c.forum_ID = b.Unique_ID) as lastVisit</cfif>
from Gerobase_Forum_Categories a inner join Gerobase_Forum_Forums b on a.unique_ID = b.category_ID
where <cfif Forum_ID is not 0> a.Unique_ID = #Forum_ID# and</cfif> a.Role_View in (#session.forumStruct.User_Role_List#)
order by a.Num_Order, b.Num_Order
</cfquery>
select a.name as category_name, a.Role_Moderate,
b.unique_ID, b.title, b.description, b.Show_Description, b.Last_Post_Date, b.Last_Post_UserName,b.Last_Post_ID, b.category_ID,
b.topics, b.posts, b.locked,
<cfif session.forumStruct.Forum_User_ID is 0>null as lastVisit
<cfelse>(select max(Visit_Date) from Gerobase_Forum_TopicUserVisit c where c.user_ID = #session.forumStruct.Forum_User_ID# and c.forum_ID = b.Unique_ID) as lastVisit</cfif>
from Gerobase_Forum_Categories a inner join Gerobase_Forum_Forums b on a.unique_ID = b.category_ID
where <cfif Forum_ID is not 0> a.Unique_ID = #Forum_ID# and</cfif> a.Role_View in (#session.forumStruct.User_Role_List#)
order by a.Num_Order, b.Num_Order
</cfquery>