SunQuest
           ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Closed Thread
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:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old August 13th, 2004, 10:24 AM
bawaite bawaite is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 84 bawaite User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 50 m 45 sec
Reputation Power: 5
database querying useing max(value) for each return

Any help you can give for this would be great.

What I am trying to do is connect 2 tables and display the highest number from one of them.

Right now I have 2 tables one contains the name and description of a gallery and the other containing an image name and a Date for that gallery.

What I need to do is connect the 2 table using the gID for the gallery info and pGallery for the images and list all the galleries that have images in it, but I also want to display the most recent image for each gallery based on the date. I am trying to do this using just one query, any suggestions?

I have tried it few different ways already but the best I have gotten is it showing only one gallery.

Thank You

Reply With Quote
  #2  
Old August 13th, 2004, 01:07 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Something like:

select g.gallaryName, g.gallaryDescription, gi.imageName, gi.imageDate
from gallary g,
gallaryImages gi
where g.gid = gi.gid
and gi.imageDate = (select max(gi2.imageDate) from gallaryImages gi2 where gi2.gid = gi.gid)
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old August 13th, 2004, 01:16 PM
bawaite bawaite is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 84 bawaite User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 50 m 45 sec
Reputation Power: 5
Quote:
Originally Posted by kiteless
Something like:

select g.gallaryName, g.gallaryDescription, gi.imageName, gi.imageDate
from gallary g,
gallaryImages gi
where g.gid = gi.gid
and gi.imageDate = (select max(gi2.imageDate) from gallaryImages gi2 where gi2.gid = gi.gid)



That worked great with a slight modification to the where statment.

Thank You

Reply With Quote
Closed Thread

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > database querying useing max(value) for each return


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