Professional Web Applications Themes

using distinct - Coldfusion - Getting Started

Removed by Administrator...

  1. Moderated Post

    Default using distinct

    Removed by Administrator
    keller18 Guest
    Moderated Post

  2. #2

    Default Re: using distinct

    Yes, you can query as per your example.
    But remember that the distinct keyword will be over every column in the select
    clause.

    What do you mean by I need additional records from that record. ?

    Ken

    The Guest

  3. #3

    Default Re: using distinct

    As ScareCrow has said the distinct will compile based upon every single field
    you select, so make sure to be wise with the fields selected within the one
    query. If understood correctly what you want is to select more information
    from the record based on a distinct restaraunt name. What you may want to do
    is use 2 seperate queries. The first query will select your distinct
    restaraunt name and then in the second query you can use the data pulled from
    the first query to get the rest of the information you need within that record
    based on the restaraunt name (some sort of ID may work better however).

    JC13 Guest

  4. #4

    Default Re: using distinct

    If you are trying to do what JC13 has indicated, then there is no need for 2 queries

    Select *
    From myTable
    Where ID = (Select Distinct ID From myTable Where restaurant_name = 'blah blah')

    Ken
    The Guest

  5. #5

    Default Re: using distinct

    Sure about that Ken? I am all to familiar with the dreaded "subquery returned more than one row" message.
    Dan Guest

  6. #6

    Default Re: using distinct

    I knew you would pick me up on that Dan :)

    I was going to use IN, but did not want to confuse the OP

    Ken
    The Guest

  7. #7

    Default Re: using distinct

    Good call guys, that will work as well. I just figured the most
    straightforward way for the user would be to use 2 queries.

    keller18, per Dan and ScareCrow...using ScareCrow's query from above instead
    of "Where ID=" it would be "Where ID IN". That should work. Have you gotten
    this to work, or are you still having trouble?

    jc

    JC13 Guest

Similar Threads

  1. SQL Distinct
    By DDhillon in forum Coldfusion Database Access
    Replies: 8
    Last Post: July 27th, 03:44 AM
  2. need help on DISTINCT
    By Krechting in forum ASP Database
    Replies: 1
    Last Post: January 12th, 01:07 AM
  3. Replies: 3
    Last Post: April 18th, 12:52 PM
  4. Replies: 0
    Last Post: April 15th, 01:22 PM

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
  •  

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