If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > get latest entry

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-09-08, 09:09
homer.favenir homer.favenir is offline
Registered User
 
Join Date: Oct 2007
Location: Manila, Philippines
Posts: 132
get latest entry

hi,
can anyone please help me how to get thy latest entry in my table
my query is
Code:
SELECT
a.transid,
a.artid,
b.remarks,
b.errID

FROM tbl_transactions as a
inner join tbl_errordetail as b on (b.transid = a.transid)

where a.artid = 123
i want to get the latest entry for b.errID without grouping by

thanks in advance
__________________
Take Nothing But Pictures;
Leave Nothing But Footprints;
Kill Nothing But Time;
Reply With Quote
  #2 (permalink)  
Old 12-09-08, 09:12
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
order by mycolumn DESC
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 12-09-08, 10:04
homer.favenir homer.favenir is offline
Registered User
 
Join Date: Oct 2007
Location: Manila, Philippines
Posts: 132
i only need the record that has the highest value
__________________
Take Nothing But Pictures;
Leave Nothing But Footprints;
Kill Nothing But Time;
Reply With Quote
  #4 (permalink)  
Old 12-09-08, 10:33
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Limit 1 ?
__________________
George
Twitter | Blog
Reply With Quote
  #5 (permalink)  
Old 01-04-09, 09:53
galih galih is offline
Registered User
 
Join Date: Feb 2008
Location: Bandung - Indonesia
Posts: 15
SELECT ...
ORDER BY b.errID DESC LIMIT 1
__________________
Forum Informatika - Indonesian Informatics Online Community - http://if.web.id
Reply With Quote
  #6 (permalink)  
Old 01-04-09, 16:44
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Code:
SELECT a.transid
     , a.artid
     , b.remarks
     , b.errID
  FROM tbl_transactions AS a
INNER 
  JOIN tbl_errordetail AS b 
    ON b.transid = a.transid
   AND b.errID =
       ( SELECT MAX(errID)
           FROM tbl_errordetail 
          WHERE transid = a.transid )
 WHERE a.artid = 123
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #7 (permalink)  
Old 01-11-09, 00:33
mayz mayz is offline
SPAMMER
 
Join Date: Jan 2009
Posts: 1
You need to have an AutoID column that increaments automatically every time you add a new record.To select the most recent record,just write you SQl statement like this:

Select * from tablename order by AutoID desc
This will display the most recent records first
Hope this helps
AMY
Reply With Quote
  #8 (permalink)  
Old 01-11-09, 00:37
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
mayz, you did not understand the question

and in any case getting the latest does not "require" an auto_increment
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On