1 Reply Latest reply on Mar 28, 2007 2:55 PM by Dan Bracuk

    loop and group query on multiple list items

      We have a multiple select list box that is used to query the database.

      The problem is I can't figure out how to group the items in the output table by list item.

      For example the user may select A, C, D from a list that is sent to a query.
      This is the query we are using and it does return the correct records but we only want the list item displayed in the first row.
      <cfquery name="getdata" datasource="PestMgmtGuide">
      SELECT *
      FROM PestMgmtGuide.dbo.Insect
      WHERE iCrop='#form.icrop#'
      AND Insect IN (#ListQualify(Form.insect,"'")#)
      ORDER BY Insect, TN ASC

      The query results need to be displayed in a table like this:

      A detail1a detail2a
      detail1b detail2b
      detail1c detail2c
      C detail1a detail2a
      detail1b detail2b
      D detail1a detail2a
      detail1b detail2b
      detail1c detail2c