SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: cfoutput query

  1. #1
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    cfoutput query

    <cfquery name="Recordset2" datasource="#Request.DSN11#">
    SELECT *
    FROM b.bder, b.pdered
    Where pdered.derID = bder.derID
    </cfquery>

    <cfoutput query="Recordset2">
    <a href="details.cfm?derId=#recordset2.derid#">#Recordset2.hipName#</a></cfoutput>

    I have one table where there is one ID that matches one or more ID in the second table. I would like to be able to list out the results but only have one listing for an ID. As it is now, the ID repeats as many times as the second table has that ID in it. What can I do?

    Thanks for any help!!

  2. #2
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sooo simple, I just figured it out... GROUP the cfoutput querry! Took me all of 1 minute after I posted...lool

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    will not work reliably unless you use ORDER BY in the query

    can you show your CFOUTPUT just to confirm?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  4. #4
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just added the group="derID" part to the cfoutput query. It is naturally ordered by the current date that is added during insert...so the table with multiple cases of the same ID would be listed together due to that natural ordering.

    Could you explain what would problems can arise?

  5. #5
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    p[roblems can arise when the rows aren't returned in the order you were hoping for

    in relational databases there no such thing as natural order

    if you want order, you must use ORDER BY
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  6. #6
    SitePoint Enthusiast
    Join Date
    May 2008
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    p[roblems can arise when the rows aren't returned in the order you were hoping for

    in relational databases there no such thing as natural order

    if you want order, you must use ORDER BY
    truth!


Bookmarks

Posting Permissions

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