MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL 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 Dev Shed Forums Sponsor:
  #1  
Old June 5th, 2003, 02:45 AM
CALDJ CALDJ is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 4 CALDJ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Multi-table calculations

Hi,

I'm a newbie that's been lurking for a while, and I've searched but haven't been able to find what I'm looking for. Basically I'm running a query that is supposed to calculate the most commonly
occuring values (with some added complications). I'm running MySQL 3.23.


Here are the relevant tables. Relationship: song has many songinfo's

------------------
table song
------------------
songid
artist
song_name

------------------
table songinfo
------------------
songinfoid
songid
chord
chord_certanity
bpm
genre

I would like a query that returns the following:

artist, song_name, CHORD, BPM, GENRE

CHORD:
This returns the most popular chord based on the chord_certanity column.

Example:
D7, 2
Bm, 4
Bm, 4
D7, 2
D7, 2
Cm7,3

The CHORD would then be Bm because it has a total of 8 chord_certanity points.

BPM
This returns the most commonly occuring value in BPM.

GENRE
This returns the most commonly occuring value in GENRE.


I have been able to write separte queries for all 3 that work, but combining them into one has got me stumped. Any helping getting this to work in one query would be greatly appreciated!

Regards

Reply With Quote
  #2  
Old June 5th, 2003, 08:54 AM
Sepodati's Avatar
Sepodati Sepodati is offline
Banned
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Dec 1999
Location: Afghanistan
Posts: 14,385 Sepodati User rank is General 14th Grade (Above 100000 Reputation Level)Sepodati User rank is General 14th Grade (Above 100000 Reputation Level)Sepodati User rank is General 14th Grade (Above 100000 Reputation Level)Sepodati User rank is General 14th Grade (Above 100000 Reputation Level)Sepodati User rank is General 14th Grade (Above 100000 Reputation Level)Sepodati User rank is General 14th Grade (Above 100000 Reputation Level)Sepodati User rank is General 14th Grade (Above 100000 Reputation Level)Sepodati User rank is General 14th Grade (Above 100000 Reputation Level)Sepodati User rank is General 14th Grade (Above 100000 Reputation Level)Sepodati User rank is General 14th Grade (Above 100000 Reputation Level)Sepodati User rank is General 14th Grade (Above 100000 Reputation Level)Sepodati User rank is General 14th Grade (Above 100000 Reputation Level)Sepodati User rank is General 14th Grade (Above 100000 Reputation Level)Sepodati User rank is General 14th Grade (Above 100000 Reputation Level)Sepodati User rank is General 14th Grade (Above 100000 Reputation Level)Sepodati User rank is General 14th Grade (Above 100000 Reputation Level)  Folding Points: 78133 Folding Title: Intermediate FolderFolding Points: 78133 Folding Title: Intermediate FolderFolding Points: 78133 Folding Title: Intermediate FolderFolding Points: 78133 Folding Title: Intermediate Folder
Time spent in forums: 2 Months 4 Weeks 1 Day 2 h 33 m 46 sec
Reputation Power: 1915
Send a message via ICQ to Sepodati Send a message via Yahoo to Sepodati
I think it'll have to remain in mulitple queries. No way that I know of to combine things like when, esp. when you're looking for "max(count())" of one column, "max(count())" of another column, "max(sum())" of another column... etc....

Even if you could, it'd probably be simpler to do 3 easy queries than one complex one.

---John Holmes...

Reply With Quote
  #3  
Old June 5th, 2003, 12:14 PM
CALDJ CALDJ is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 4 CALDJ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks! I'll try to run all three that puts them into a temp table.

Regards

Reply With Quote
  #4  
Old June 5th, 2003, 01:25 PM
CALDJ CALDJ is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 4 CALDJ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks! I'll try to run all three that puts them into a temp table.

Regards

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Multi-table calculations


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 5 hosted by Hostway
Stay green...Green IT