MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

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 October 19th, 2012, 08:23 AM
ParisByNight ParisByNight is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 1 ParisByNight User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 35 m 39 sec
Reputation Power: 0
Select max

Hello all.

I have 2 tables,
- Users with userId, userName
- Affiliations with id, affiliationId, affiliationStartDate, affiliationEndDate

How to find in a select all guys that haven't renew their affiliation before a certain date ?
So I'm looking for userName and max(affiliationEndDate) where max(affiliationEndDate) < '2012-11-01' ?

I'm using MySql 3.23.58

Yhanks for your help

Reply With Quote
  #2  
Old October 19th, 2012, 11:12 AM
sr sr is offline
Problem Solver
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Jan 2001
Location: Stockholm, Sweden
Posts: 4,434 sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 8 h 1 m 53 sec
Reputation Power: 532
Something like this (not verified):
Code:
SELECT
  u.userName
  ,max(a.affiliationEndDate)
FROM
  users u
INNER
  JOIN
    affiliations a
    ON u.userid = a.id
GROUP
  BY
    u.userName
HAVING
  max(a.affiliationEndDate) < '2012-11-01'


Quote:
Originally Posted by ParisByNight
I'm using MySql 3.23.58

Holy cr*p!
If you still use a software from 2003 I wonder how old your car is. Or if you work for NASA and have a really long procurement time.
__________________
/Stefan

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Select max

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap