Skip to main content
Inspiring
February 29, 2008
Question

Multiple or Single Query?

  • February 29, 2008
  • 2 replies
  • 328 views
I am trying building a ConstituencyMap of electoral Constituencies each of which a couple of polling stations. I want to output information containing the Name and Region of each constituency and also a running total of the votes from each polling station in that constituency until all polling stations in that constituency have reported their results. Further more I will use a query to find out which party won and change the color of the cell to the parties assigned color.

My question is how do I get all this information in a single cell. I do not know if I can use multiple query values in the same logic. For example, my code to show the constituency name and region is as attached. Being a novice in databases, I would rather use multiple queries and try to add the results to the cell, but I do not know if this is possible, I think a single query drawing information from my multiple table would be the way to go, but this would be a complex query.

I will appreciate any insight into this. Thanks
    This topic has been closed for replies.

    2 replies

    Inspiring
    February 29, 2008
    As well as Dan's suggestion for "Teach Yourself SQL in 10 Minutes" by
    Ben Forta.

    You can reference multiple queries. You just have to reference the
    record set data structure yourself, rather then relying on a shortcut
    such as <cfoutput query="aQuery">

    A fully qualified record set reference is queryName.columnName[row] OR
    queryName['columnName'][row].

    I.E.

    <cfquery name="aQry".../>
    <cfquery name="bQry".../>

    <cfoutput>
    #aQry.aColumn[1]# <---> #bQry['bColumn][2]
    </cfoutput>

    Inspiring
    February 29, 2008
    If you don't know how to select from more than one table at a time, I have heard good things about the book, Teach Yourself SQL in 10 Minutes by Ben Forta.