|
|
|
| If I query a table that has dates and brings up multiple results, how can I
display only the one that was last entered based on the 'date' field ?
Select * from table
Where ....
'date' is the field that has the date in which the record was last updated.
Aleks
| |
|
| oder by date and select your firt or last one.
--
::-----::-----::
thanks,
Jon Parkhurst
PriivaWeb, Inc.
http://priiva.net
I don't wanna grow up, I'm a ToysRUs Kid....
"Aleks" <arkark2004@hotmail.com> wrote in message
news:d0qc7p$3e7$1@forums.macromedia.com...
> If I query a table that has dates and brings up multiple results, how can
> I display only the one that was last entered based on the 'date' field ?
>
> Select * from table
>
> Where ....
>
> 'date' is the field that has the date in which the record was last
> updated.
>
> Aleks
>
| |
|
| How do I select the first one ?
A
"crash" <admin@NOMAILstormwraith.net> wrote in message
news:d0qcae$3hm$1@forums.macromedia.com...
> oder by date and select your firt or last one.
>
> --
>
>
> ::-----::-----::
>
> thanks,
>
> Jon Parkhurst
> PriivaWeb, Inc.
> http://priiva.net
>
> I don't wanna grow up, I'm a ToysRUs Kid....
> "Aleks" <arkark2004@hotmail.com> wrote in message
> news:d0qc7p$3e7$1@forums.macromedia.com...
>
>
| |
|
| This is the part of my query where I need to specify to bring only the
latest one.
left join casecomments as b on a.id = b.caseid
From table "b" the field "LastUpdated" should be the latest one only.
A
"Aleks" <arkark2004@hotmail.com> wrote in message
news:d0qd0j$4na$1@forums.macromedia.com...
> How do I select the first one ?
>
> A
>
>
> "crash" <admin@NOMAILstormwraith.net> wrote in message
> news:d0qcae$3hm$1@forums.macromedia.com...
>
>
| |
|
| you in sql? mine's rusty and i've not books here currently to help you.
can you sort b.LastUpdate ASSEND?
I'll try to look around and find out if I can gets osme paper to de-handicap
me
--
::-----::-----::
thanks,
Jon Parkhurst
PriivaWeb, Inc.
http://priiva.net
I don't wanna grow up, I'm a ToysRUs Kid....
"Aleks" <arkark2004@hotmail.com> wrote in message
news:d0qdav$55b$1@forums.macromedia.com...
> This is the part of my query where I need to specify to bring only the
> latest one.
>
> left join casecomments as b on a.id = b.caseid
>
> From table "b" the field "LastUpdated" should be the latest one only.
>
> A
>
>
>
> "Aleks" <arkark2004@hotmail.com> wrote in message
> news:d0qd0j$4na$1@forums.macromedia.com...
>
>
| |
| darrel 2005-03-10, 6:35 pm |
| > How do I select the first one ?
SELECT TOP 1 whatever FROM whatever WHERE whatever SORT BY dateField DESC
-Darrel
| |
|
| Not so simple, that is part of a query, if I simply do this:
SELECT TOP 1 * FROM casecomments Order BY LastUpdate DESC
It gives me the last comment
But that is a left join I am doing from this statement, the second line
where I left join the 'casecomments' should only return the last updated
comment:
Select * from cases
left join casecomments as b on a.id = b.caseid
---------------------------------HERE SHOULD RETURN ONLY THE LAST
UPDATED RECORD ----------------------------------
left join users as f on a.empid = f.userid
inner join users as d on a.alienid = d.userid
left join employment as L on d.userid=L.userid and l.curemp = 1
inner join processcatalog as e ON e.processcatalogid = a.process
inner join users as h on b.Updatedby = h.userid
WHERE a.firmid = 2
ORDER BY f.MaidenNm, a.caseid
So I really don't know how to add that selection criteria to the left join
a
"darrel" <notreal@hotmail.com> wrote in message
news:d0qdel$59u$1@forums.macromedia.com...
>
> SELECT TOP 1 whatever FROM whatever WHERE whatever SORT BY dateField DESC
>
> -Darrel
>
>
| |
| CMBergin 2005-03-10, 6:35 pm |
| It's sometimes easier not to join the table:
Select * from cases
left join casecomments as b on a.id = b.caseid AND b.lastupdate = (SELECT
MAX(x.lastupdate) FROM casecomments x WHERE x.caseid=a.id)
left join users as f on a.empid = f.userid
inner join users as d on a.alienid = d.userid
left join employment as L on d.userid=L.userid and l.curemp = 1
inner join processcatalog as e ON e.processcatalogid = a.process
inner join users as h on b.Updatedby = h.userid
WHERE a.firmid = 2
ORDER BY f.MaidenNm, a.caseid
"Aleks" <arkark2004@hotmail.com> wrote in message
news:d0qdtt$61b$1@forums.macromedia.com...
> Not so simple, that is part of a query, if I simply do this:
> SELECT TOP 1 * FROM casecomments Order BY LastUpdate DESC
> It gives me the last comment
>
> But that is a left join I am doing from this statement, the second line
> where I left join the 'casecomments' should only return the last updated
> comment:
>
> Select * from cases
> left join casecomments as b on a.id = b.caseid
> ---------------------------------HERE SHOULD RETURN ONLY THE LAST
> UPDATED RECORD ----------------------------------
> left join users as f on a.empid = f.userid
> inner join users as d on a.alienid = d.userid
> left join employment as L on d.userid=L.userid and l.curemp = 1
> inner join processcatalog as e ON e.processcatalogid = a.process
> inner join users as h on b.Updatedby = h.userid
> WHERE a.firmid = 2
> ORDER BY f.MaidenNm, a.caseid
>
>
> So I really don't know how to add that selection criteria to the left join
>
>
> a
>
>
>
>
>
> "darrel" <notreal@hotmail.com> wrote in message
> news:d0qdel$59u$1@forums.macromedia.com...
DESC[color=darkred]
>
>
|
|
|
|
| Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |