PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > mysql.general > Re: Selecting the most recent entry for each object.
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Re: Selecting the most recent entry for each object.

Réponse
 
LinkBack Outils de la discussion
Vieux 20/03/2008, 15h54   #1
Baron Schwartz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Selecting the most recent entry for each object.

Hi,

On Thu, Mar 20, 2008 at 10:35 AM, Edward Corbett <edward@craft-e.com> wrote:
> Hi,
>
>
>
> I have a load of reviews in a table and, for each person I want to pull out
> the most recent review.
>
>
>
> So, if I wanted to do this for a single person I would order by date desc
> and use "limit 1". But I'm not sure how to do this in bulk.


Try the techniques I wrote about here:
http://www.xaprb.com/blog/2006/12/07...-group-in-sql/

Baron
  Réponse avec citation
Vieux 20/03/2008, 17h38   #2
Edward Corbett
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: Selecting the most recent entry for each object.

Great article. Got me on the right track.

Actual solution I went with was something like:

select
`vPamLearner`.`learnerId`,
`vPamLearner`.`usedName`,
`vPamLearner`.`surname`,
max(prComp.dateSubmitted) latestSubmitted,
max(prComp.FProgressReviewId) latestSubmittedId,
max(prStarted.dateStarted) latestStarted,
max(prStarted.FProgressReviewId) latestStartedId
from vPamLearner
left join vPamFProgressReview prComp on vPamLearner.learnerId =
prComp.learnerId and prComp.status = 'c'
left join vPamFProgressReview prStarted on vPamLearner.learnerId =
prStarted.learnerId and prStarted.status = 's'
where
`vPamLearner`.`assessorId` = 5
group by `vPamLearner`.`learnerId`;

Cheers

-----Original Message-----
From: baron.schwartz@gmail.com [mailto:baron.schwartz@gmail.com] On Behalf
Of Baron Schwartz
Sent: 20 March 2008 14:54
To: edward@craft-e.com
Cc: mysql@lists.mysql.com
Subject: Re: Selecting the most recent entry for each object.

Hi,

On Thu, Mar 20, 2008 at 10:35 AM, Edward Corbett <edward@craft-e.com> wrote:
> Hi,
>
>
>
> I have a load of reviews in a table and, for each person I want to pull

out
> the most recent review.
>
>
>
> So, if I wanted to do this for a single person I would order by date desc
> and use "limit 1". But I'm not sure how to do this in bulk.


Try the techniques I wrote about here:
http://www.xaprb.com/blog/2006/12/07...astmax-row-per
-group-in-sql/

Baron



  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 10h57.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09309 seconds with 10 queries