Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers 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 September 25th, 2003, 07:00 PM
ahprophet ahprophet is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 12 ahprophet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to ahprophet Send a message via Yahoo to ahprophet
Query Question - MYSQL

My Query

SELECT COUNT(DISTINCT TBVIEWER_TRACK.VIEWER_ID) AS COUNT, TITLE FROM TBVIEWER_TRACK INNER JOIN TBPRESENTATIONS USING(PRESENTATION_ID) WHERE TBPRESENTATIONS.PRESENTER_ID='2' AND COUNT < 5 GROUP BY TITLE;

My Error: Uknown column 'COUNT' in 'where clause'

Any ideas??

Reply With Quote
  #2  
Old September 25th, 2003, 10:05 PM
honcho's Avatar
honcho honcho is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Cape Cod
Posts: 1,347 honcho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 2 sec
Reputation Power: 3
RE: Query Question - MYSQL

It's probably getting confused between the column you named COUNT and the COUNT function. Try changeing the column alias to something else, like CNT.

Reply With Quote
  #3  
Old September 26th, 2003, 01:21 PM
ahprophet ahprophet is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 12 ahprophet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to ahprophet Send a message via Yahoo to ahprophet
RE: Query Question - MYSQL

hey thanx for the response, i tried that to no avail. i got the same error message.

perhaps i am approaching the query wrong as i am not very experienced in MYSQL yet.

the tables are organized as such. table names will be all capitals and the fields will be lower case.

TBPRESENTATIONS
presentation_id
presenter_id
title
start

TBVIEWER_TRACK
viewer_id

TBPRESENTERS
presenter_id
number_licenses

How it all works is each presenter is given a number of licenses (number_licenses). The licenses determine how many viewers can watch the presentation which can be found by counting the unique viewer ids( count(distinct viewer_id) ).

What I am trying to extract is the number of viewers exceeding the number of specified licenses per presenter. I also need the date of the presentation(start) and the name (title).

Thanx to anyone that attempts to help me out!

Reply With Quote
  #4  
Old September 26th, 2003, 03:55 PM
honcho's Avatar
honcho honcho is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Cape Cod
Posts: 1,347 honcho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 2 sec
Reputation Power: 3
RE: Query Question - MYSQL

How do you tie a viewer to a presenter or a presentation?

Reply With Quote
  #5  
Old September 26th, 2003, 04:06 PM
ahprophet ahprophet is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 12 ahprophet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to ahprophet Send a message via Yahoo to ahprophet
RE: Query Question - MYSQL

im sorry, i left out a field

TBPRESENTATIONS
presentation_id
presenter_id
title
start

TBVIEWER_TRACK
presentation_id
viewer_id

TBPRESENTERS
presenter_id
number_licenses

so...
-TBVIEWER_TRACK has the 'presentation_id'.
'presentation_id' is a common field and can be used in a join between TBVIEWER_TRACK and TBPRESENTATIONS if necessary

-TBPRESENTATIONS and TBPRESENTERS have a common field in 'presenter_id'

sorry for the confusion.

Reply With Quote
  #6  
Old September 26th, 2003, 07:19 PM
honcho's Avatar
honcho honcho is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Cape Cod
Posts: 1,347 honcho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 2 sec
Reputation Power: 3
RE: Query Question - MYSQL

I should have looked at your original post more closely. The problem is that you are putting a condition on the count column in the where clause and not in the group by's having clause. Something like this should work:

Code:
SELECT
TBPRESENTATIONS.title AS Title,
COUNT(DISTINCT TBVIEWER_TRACK.viewer_id) AS Cnt,
FROM TBVIEWER_TRACK
INNER JOIN TBPRESENTATIONS USING(presentation_id)
LEFT JOIN TBPRESENTERS USING(presenter_id)
GROUP BY TBPRESENTATIONS.presentation_id HAVING Cnt > TBPRESENTERS.number_licenses;

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Query Question - MYSQL


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