Professional Web Applications Themes

RAND() not allowed in query of queries? - Coldfusion - Advanced Techniques

I was thinking about a custom tag to output any query passed to it in random order. The easiest solution seemed to be to do a QoQ on the passed in query and output that, doing something like: SELECT * FROM queryName ORDER BY RAND() LIMIT #attributes.limit# The RAND() call, in particular the (, throws a syntax error. Can I do this, or is RAND() not a part of the QoQ syntax?...

  1. #1

    Default RAND() not allowed in query of queries?

    I was thinking about a custom tag to output any query passed to it in random
    order. The easiest solution seemed to be to do a QoQ on the passed in query and
    output that, doing something like:

    SELECT * FROM queryName ORDER BY RAND() LIMIT #attributes.limit#

    The RAND() call, in particular the (, throws a syntax error. Can I do this, or
    is RAND() not a part of the QoQ syntax?

    mate Guest

  2. #2

    Default Re: RAND() not allowed in query of queries?

    the normal syntax for functions is to put something between the brackets. Plus, rand() does not work inside QofQ.
    Dan Guest

  3. #3

    Default Re: RAND() not allowed in query of queries?

    Perhaps putting octothorps around the RAND() function would work: #RAND()#(thanks for the new word, Dan) :-)
    jdeline Guest

  4. #4

    Default Re: RAND() not allowed in query of queries?

    " the normal syntax for functions is to put something between the brackets."

    Uh, yeah... *if* they are receiving any arguments...

    "Plus, rand() does not work inside QofQ."

    Haha, and there it is. The simple, relevant part of the response second.
    Thanks.

    " Perhaps putting octothorps around the RAND() function would work: #RAND()#"

    It would work, but would give the wrong results because I actually want the
    SQL function rand(), not the ColdFusion one. Hence why I wrote what I did.



    mate Guest

  5. #5

    Default Re: RAND() not allowed in query of queries?

    Any functions that are database specific are not likely to work in Q of Q.

    Originally posted by: mate of the state
    " the normal syntax for functions is to put something between the brackets."

    Uh, yeah... *if* they are receiving any arguments...

    "Plus, rand() does not work inside QofQ."

    Haha, and there it is. The simple, relevant part of the response second.
    Thanks.

    " Perhaps putting octothorps around the RAND() function would work: #RAND()#"

    It would work, but would give the wrong results because I actually want the
    SQL function rand(), not the ColdFusion one. Hence why I wrote what I did.





    Dan Guest

Similar Threads

  1. Query of Queries with constructed query using QueryNew()and QueryAddRow()
    By LeadFoot in forum Coldfusion - Advanced Techniques
    Replies: 2
    Last Post: August 4th, 02:00 PM
  2. query of queries with avg()
    By gogl in forum Coldfusion - Getting Started
    Replies: 3
    Last Post: July 6th, 09:50 PM
  3. 2 queries to 1 query
    By Samall in forum Macromedia ColdFusion
    Replies: 4
    Last Post: May 26th, 12:29 PM
  4. Query of Queries on query New type query
    By david_h in forum Coldfusion Database Access
    Replies: 2
    Last Post: May 6th, 08:55 PM
  5. no database query is allowed yet value is still returned
    By lawrence in forum PHP Development
    Replies: 2
    Last Post: July 10th, 05:56 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