This is a multi-part message in MIME format.

------=_NextPart_000_026A_01C02496.B094CCD0
Content-Type: text/plain;
        charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

SQL Select Max + a column

How about:

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



DC

  -----Original Message-----
  From: Mark Warrick [mailto:[EMAIL PROTECTED]]
  Sent: Friday, September 22, 2000 08:28
  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/[email protected]/
  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.


------=_NextPart_000_026A_01C02496.B094CCD0
Content-Type: text/html;
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>SQL Select Max + a column</TITLE>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.3018.900" name=3DGENERATOR></HEAD>
<BODY>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D901171113-22092000></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D901171113-22092000></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN =
class=3D901171113-22092000>How=20
about:</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D901171113-22092000></SPAN></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D901171113-22092000>
<P><FONT size=3D2><FONT color=3D#0000ff><FONT=20
face=3DArial>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SELECT =
ID_ENC_TOY_IMAGE,=20
ENC_TOY_IMAGE_LINK_TEXT <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
FROM=20
ENC_TOY_IMAGE <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WHERE =
ID_ENC_TOY =3D=20
#ID_ENC_TOY#&nbsp;<SPAN class=3D901171113-22092000> GROUP BY =
ENC_TOY_IMAGE,=20
ENC_TOY_IMAGE_LINK_TEXT</SPAN></FONT></FONT></FONT></P>
<P><FONT size=3D2><FONT color=3D#0000ff><FONT face=3DArial><SPAN=20
class=3D901171113-22092000></SPAN></FONT></FONT></FONT>&nbsp;</P>
<P><FONT size=3D2><FONT color=3D#0000ff><FONT face=3DArial><SPAN=20
class=3D901171113-22092000>DC</SPAN></FONT></FONT></FONT></P></SPAN></DIV=
>
<BLOCKQUOTE style=3D"MARGIN-RIGHT: 0px">
  <DIV align=3Dleft class=3DOutlookMessageHeader dir=3Dltr><FONT =
face=3DTahoma=20
  size=3D2>-----Original Message-----<BR><B>From:</B> Mark Warrick=20
  [mailto:[EMAIL PROTECTED]]<BR><B>Sent:</B> Friday, September 22, 2000=20
  08:28<BR><B>To:</B> CF-Talk<BR><B>Subject:</B> SQL Select Max + a=20
  column<BR><BR></DIV></FONT>
  <P><FONT size=3D2>I'm trying to do this:</FONT> </P>
  <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=3D2>SELECT=20
  ID_ENC_TOY_IMAGE, ENC_TOY_IMAGE_LINK_TEXT</FONT>=20
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=3D2>FROM=20
  ENC_TOY_IMAGE</FONT> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
<FONT=20
  size=3D2>WHERE ID_ENC_TOY =3D #ID_ENC_TOY#</FONT> </P>
  <P><FONT size=3D2>But I want the max ID_ENC_TOY_IMAGE row.</FONT> </P>
  <P><FONT size=3D2>I've tried:</FONT> </P>
  <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=3D2>SELECT =
max=20
  (ID_ENC_TOY_IMAGE) as maxid, ENC_TOY_IMAGE_LINK_TEXT</FONT>=20
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=3D2>FROM=20
  ENC_TOY_IMAGE</FONT> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
<FONT=20
  size=3D2>WHERE ID_ENC_TOY =3D #ID_ENC_TOY#</FONT> </P>
  <P><FONT size=3D2>But I get an aggregate error.</FONT> </P>
  <P><FONT size=3D2>If I leave off the extra column it works fine, but =
of course=20
  then I'd have to run another query to get the remaining info I=20
need.</FONT></P>
  <P><FONT size=3D2>I could also select all records and then order them =
in=20
  descending order by ID_ENC_TOY_IMAGE, but that seems like an awful =
waste of=20
  processor power.</FONT></P>
  <P><FONT size=3D2>Anyone know how to do this the right way?</FONT> =
</P>
  <P><FONT=20
  =
size=3D2>--------------------------------------------------------------</=
FONT>=20
  <BR><FONT size=3D2>Mark Warrick</FONT> <BR><FONT size=3D2>Phone: (714) =

  547-5386</FONT> <BR><FONT size=3D2>Efax.com Fax: (801) 730-7289</FONT> =
<BR><FONT=20
  size=3D2>Personal Email: [EMAIL PROTECTED]</FONT> <BR><FONT =
size=3D2>Personal URL:=20
  <A href=3D"http://www.warrick.net" =
target=3D_blank>http://www.warrick.net</A>=20
  </FONT><BR><FONT size=3D2>Business Email: [EMAIL PROTECTED]</FONT> =
<BR><FONT=20
  size=3D2>Business URL: <A href=3D"http://www.fusioneers.com"=20
  target=3D_blank>http://www.fusioneers.com</A></FONT> <BR><FONT =
size=3D2>ICQ:=20
  346566</FONT> <BR><FONT=20
  =
size=3D2>--------------------------------------------------------------</=
FONT>=20
  </P>
  <P><FONT=20
  =
size=3D2>----------------------------------------------------------------=
--------------</FONT>=20
  <BR><FONT size=3D2>Archives: <A=20
  href=3D"http://www.mail-archive.com/[email protected]/"=20
  =
target=3D_blank>http://www.mail-archive.com/[email protected]/</A=
></FONT>=20
  <BR><FONT size=3D2>To Unsubscribe visit <A=20
  =
href=3D"http://www.houseoffusion.com/index.cfm?sidebar=3Dlists&amp;body=3D=
lists/cf_talk"=20
  =
target=3D_blank>http://www.houseoffusion.com/index.cfm?sidebar=3Dlists&am=
p;body=3Dlists/cf_talk</A>=20
  or send a message to [EMAIL PROTECTED] with =
'unsubscribe' in=20
  the body.</FONT></P></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_026A_01C02496.B094CCD0--

------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
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