MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old March 24th, 2008, 11:26 PM
wconti wconti is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 2 wconti User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 25 sec
Reputation Power: 0
Help-a-newb with query ...

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

Reply With Quote
  #2  
Old April 10th, 2008, 09:14 PM
dykebert's Avatar
dykebert dykebert is offline
Contributing User
Click here for more information. Click here for more information
 
Join Date: Apr 2008
Posts: 220 dykebert User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 9 h 10 m 37 sec
Reputation Power: 1
OK. I don't know MsSQL so this may be way off base.

But if I read your last condition correctly you want to filter the records according to the value of the users.testonly field. However the users table is not part of your FROM statement. Based on your select you'll need to change the FROM statement to something like:

from
((threads inner join users on threads.author = users.name)
inner join forums on threads.forumidfk = forums.id)
inner join conferences on forums.conferenceidfk = conferences.id

Basically you can't use a table in the WHERE clause that isn't part of the FROM clause.

Hope this helps.

Reply With Quote
  #3  
Old April 10th, 2008, 09:53 PM
wconti wconti is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 2 wconti User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 25 sec
Reputation Power: 0
Quote:
Originally Posted by dykebert
OK. I don't know MsSQL so this may be way off base.

But if I read your last condition correctly you want to filter the records according to the value of the users.testonly field. However the users table is not part of your FROM statement. Based on your select you'll need to change the FROM statement to something like:

from
((threads inner join users on threads.author = users.name)
inner join forums on threads.forumidfk = forums.id)
inner join conferences on forums.conferenceidfk = conferences.id

Basically you can't use a table in the WHERE clause that isn't part of the FROM clause.

Hope this helps.


Thank you very much "dykebert" I am almost getting there

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > Help-a-newb with query ...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway