Mark
How about sth like

SELECT ID_ENC_TOY_IMAGE, ENC_TOY_IMAGE_LINK_TEXT
FROM   ENC_TOY_IMAGE
WHERE  ID_ENC_TOY = 
      (SELECT max(ID_ENC_TOY_IMAGE)
       FROM ENC_TOY_IMAGE
       WHERE ID_ENC_TOY = #ID_ENC_TOY#)

Nick

-----Original Message-----
From: Mark Warrick [mailto:[EMAIL PROTECTED]]
Sent: Friday, September 22, 2000 9:28 AM
To: CF-Talk
Subject: SQL Select Max + a column


I'm trying to do this:

        SELECT ID_ENC_TOY_IMAGE, ENC_TOY_IMAGE_LINK_TEXT
        FROM ENC_TOY_IMAGE
        WHERE ID_ENC_TOY = #ID_ENC_TOY#

But I want the max ID_ENC_TOY_IMAGE row.

I've tried:

        SELECT max (ID_ENC_TOY_IMAGE) as maxid, ENC_TOY_IMAGE_LINK_TEXT
        FROM ENC_TOY_IMAGE
        WHERE ID_ENC_TOY = #ID_ENC_TOY#

But I get an aggregate error.

If I leave off the extra column it works fine, but of course then I'd have
to run another query to get the remaining info I need.

I could also select all records and then order them in descending order by
ID_ENC_TOY_IMAGE, but that seems like an awful waste of processor power.

Anyone know how to do this the right way?

--------------------------------------------------------------
Mark Warrick
Phone: (714) 547-5386
Efax.com Fax: (801) 730-7289
Personal Email: [EMAIL PROTECTED]
Personal URL: http://www.warrick.net 
Business Email: [EMAIL PROTECTED]
Business URL: http://www.fusioneers.com
ICQ: 346566
--------------------------------------------------------------

----------------------------------------------------------------------------
--
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.


**********************************************************************
Information in this email is confidential and may be privileged. 
It is intended for the addressee only. If you have received it in error,
please notify the sender immediately and delete it from your system. 
You should not otherwise copy it, retransmit it or use or disclose its
contents to anyone. 
Thank you for your co-operation.
**********************************************************************
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to