You can also try: Select SUBSTRING( MAX( CONCAT(LPAD(calltime,6,'0'),finishcode) ), 7) AS finishcode, 0+LEFT( MAX( CONCAT(LPAD(calltime,6,'0'),finishcode )), 6) AS calltime >From callhistory As H,calllist As L where H.rowid = L.rowid group by H.rowid
This is from: http://www.mysql.com/doc/e/x/example-Maximum-column-group-row.html Although it's regarded as 'inefficient', but you can do it in one statement. Regards, Dan > -----Original Message----- > From: DL Neil [mailto:[EMAIL PROTECTED]] > Sent: Thursday, 21 February 2002 11:18 a.m. > To: David McInnis; 'Shade, Richard'; [EMAIL PROTECTED] > Subject: Re: MYSQL HELP > > > David, > > > How would you use a temporary table? Is that the most efficient way? > > Use SELECT INTO temp_tbl to replace the sub-select clause. > Rewrite the existing SELECT into a join with the temp_tbl. > > Is there another way? > > =dn > > > > Richard, > > > > > Does anyone know what is wrong with this syntax... > > > > > > Select H.FinishCode, L.RowID > > > From CallHistory As H, BD2.CallList As L > > > Where (H.CallTime in(Select MAX(CallTime) From CallHistory Where > > H.RowID = > > > L.RowID) > > > AND H.RowID = L.RowID); > > > > > > Sub-selects not (yet) permitted by MySQL (RTFM: 1.7.4.1 Sub-SELECTs) > > Looks like a job for two SELECTs and a temporary table... > > > > Regards, > > =dn > > > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail > <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php