multiple queries and cfgrid

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default multiple queries and cfgrid

    Hi,
    I have a soccer(futbol, for some of you folks) standings page. I have it all
    working perfectly within a standard html page just fine. I want to change it
    over to a cfgrid. The problem is, I have multiple queries, and it seems as if
    cfgrid can only handle one query. I have 2 main queries and about 13 different
    subqueries that I would like to combine into one so that I can use cfgrid. I
    wont bore you with every single query but if I can be pointed in the right
    direction, I am sure I can figure the rest out.

    First main query:
    <cfquery name="getteams" datasource="#ds#">
    SELECT teamname
    FROM teams
    WHERE age_id = '#ageid#'
    group BY team_id
    </cfquery>

    Second main Query:
    <cfquery datasource="#ds#" name="getscores">
    SELECT home, homescore, visitor, visitorscore, homeforfeit, visitorforfeit
    FROM schedule
    WHERE age_id = '#ageid#'
    AND (home = '#getteams.teamname#'
    OR visitor = '#getteams.teamname#')
    </cfquery>

    First QofQ:
    <cfquery name="gethwins" dbtype="query">
    SELECT home
    FROM getscores
    WHERE homescore > visitorscore
    AND home = '#getteams.teamname#'
    </cfquery>

    Second QofQ:
    <cfquery name="gethloss" dbtype="query">
    SELECT homescore
    FROM getscores
    WHERE homescore < visitorscore
    AND home = '#getteams.teamname#'
    </cfquery>

    Third QofQ:
    <cfquery name="gethgf" dbtype="query">
    select sum(homescore) as hgf
    from getscores
    where home = '#getteams.teamname#'
    and homescore is not null
    </cfquery>

    Like I said there are several other QofQ's, but this is the jist of it. Can
    someone help me out on what I need to do combine these into one query so that I
    can use cfgrid? TIA.

    rmorgan Guest

  2. Similar Questions and Discussions

    1. CFGRID and Multiple CFSELECTS
      I am modifying the address book similar to the one shown http://www.asfusion.com/blog/examples/cfdj/ execpt that I have 2 dropdowns: Grade and...
    2. Cfgrid multiple tables
      I have a cfgrid with 3 columns, employee_ID, employee_Name, employee_level. I keep employee_level_ID in the employee talbe and map it to the...
    3. Multiple DSN queries
      I can easily query multiple DSNs in the same CF query, using CFMX 6.1 and win 2000. Unfortunately i am unable to perform the same query on a win2003...
    4. CF Multiple Queries, Multiple Records
      All, I've got three queries all passing variables from previous queries. The issues? The second query returns 4 records. I want to use IDs for...
    5. posting multiple queries
      This is puzzling. If I run $sql = "INSERT INTO customer...
  3. #2

    Default Re: multiple queries and cfgrid

    You might look into either sql subqueries or using some type of CASE statements
    (ie. sql 'case' operator or your database's equivalent). However, a lot
    depends on the different levels of information you are trying to display in
    your final results and how many tables you are querying. What tables are you
    querying (overall)? What information are you retreiving/displaying?



    mxstu Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139