query1[query2.field] is incorrect

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default query1[query2.field] is incorrect

    I'm trying to reference one query by the output of another. For example:

    The output of query1.field is "first_name"

    I want to somehow use this output of "query1.field" and use it in a reference,
    like so:

    query2."query1.field"
    --or--
    query2.first_name

    I tried looking in documentation, etc, but I can't find any help on this
    topic. I can do something similar with forms: FORM[query1.field] (which I
    learned on macromedia forums), but can't seem to find a way to do it between
    queries.

    Am I asking too much? Is there another approach to this?

    Please help.

    dobaldwin Guest

  2. Similar Questions and Discussions

    1. Forms: Text field - auto fill another field?
      Someone PLEASE help me... how do i structure a form so that when text is entered into one field, it auto-fills other fields on the form that are...
    2. Comparing current field data with last entry for field
      Hi. I have a form that is inserting sales data on a daily basis. I have a field named "RoundTOTAL" which is the total sales for the day rounded to...
    3. Defined text field in form -> subject field in e-mail
      Hi, I have a form on my web site which users send to me by mailto-function. I would like the text they write in a particular text field to...
    4. Linking date field to text field entry
      Is there a way to setup a date field that will automatically enter the date when any information is entered into a field next to it?
    5. Curved Field vs Flat Field projector lenses
      I was looking thru Adorama's page and came across two Kodak projector lenses. One was a 102/2.8 "Curved Lens" the other a 100/2.8 "Flat Lens" and...
  3. #2

    Default Re: query1[query2.field] is incorrect

    When using array notation for queries, you need to specify the query row number: query[columnname][rownumber]

    <cfoutput query="query2">
    #query2[query1.Field][currentRow]#<br>
    </cfoutput>

    mxstu Guest

  4. #3

    Default Re: query1[query2.field] is incorrect

    Hm... still trying to get it to work correctly. This is what I have:

    <cfloop query="query1">
    #query1.field1#
    <cfloop query="query2">
    #query2[query1.Field][currentRow]#<br>
    </cfloop>
    </cfloop>

    Isn't there anything like Javascript's Evaluate() function?

    Again, thanks for the help!

    dobaldwin Guest

  5. #4

    Default Re: query1[query2.field] is incorrect

    I'm an idiot. My last post answered my own question. There is an Evaluate
    function in ColdFusion. Here it is in action:

    <cfloop query="query1">
    #query1.field1#
    #Evaluate("query2.#query1.field#")#
    </cfloop>

    Thanks everybody for putting up with me while I thought this one through.

    dobaldwin Guest

  6. #5

    Default Re: query1[query2.field] is incorrect

    Originally posted by: dobaldwin
    There is an Evaluate function in ColdFusion ....


    Yes, Evaluate() does work, but is not necessary here to get the job done. Try
    and avoid using Evaluate() unless it is absolutely necessary, as it requires
    more processing than a straight output. I'm not certain what information you
    are trying to output, but if you are only need to output the first row in
    "query2", the attached does the same thing without using Evaluate().



    <cfoutput query="query1">
    #query1.field#<br>
    #query2[query1.Field][1]#<br>
    </cfoutput>

    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