Groups > Databases > MySQL for ASP.NET > Help-a-Newb with query




Help-a-Newb with query

Help-a-Newb with query
Tue, 25 Mar 2008 03:41:10 +000
select distinct
threads.id, 
threads.name, 
threads.readonly, 
threads.active, 
threads.forumidfk, 
threads.useridfk, 
threads.author,
threads.datecreated, 
forums.name as forum, 
threads.author as username,
threads.sticky,
threads.views,
conferences.name as conference,
conferences.id as conferenceid,                        
threads.lastpost,
threads.msgcount as messagecount
 
from 
(threads inner join forums on threads.forumidfk = forums.id)
inner join conferences on forums.conferenceidfk = conferences.id
 
where 1=1 
<cfif arguments.bActiveOnly>
   and threads.active = 1
</cfif>
<cfif isDefined("arguments.forumid")>
 and threads.forumidfk = <cfqueryparam value="#arguments.forumid#"
cfsqltype="CF_SQL_VARCHAR" maxlength="35">
</cfif>

            
======================================

... as it is now it works fine but I need to add the following condition :
            
<cfif isDefined("arguments.testOnly") and arguments.testOnly IS
1>
 and users.testOnly = <cfqueryparam value="#arguments.testOnly#"
cfsqltype="CF_SQL_SMALLINT">
</cfif>

please help with the [select] and [from] (inner join?). Thank you very much.    
      

=====================================      
            

order by threads.sticky desc, threads.lastpost desc
Post Reply
about | contact