5

Take the following query example:

<cfquery name="Test" Datasource = "TestDB">
    Select * from Table_Test
</cfquery>

Assume that the "Test" query returns 10 rows. I want to show single row on current time.

Note: I do not want to change the SQL statement.

Mohanrajan
  • 721
  • 9
  • 18
  • 4
    The sentence, "I want to show single row on current time.", is not clear. – Dan Bracuk Oct 27 '14 at 12:28
  • 1
    I second what @DanBracuk says. I think CFML_Developer has answered your question, but that's predicated on guessing what you mean in that highlighted sentence. – Adam Cameron Oct 27 '14 at 12:45

2 Answers2

7

If you know your row number, Test.columnName[RowNumber] will show you the value of the columnName in specified row number.

Community
  • 1
  • 1
CFML_Developer
  • 1,565
  • 7
  • 18
  • Yes brother you are right.But the table has minimum 50 column any way Thank you for answering this question. – Mohanrajan Oct 27 '14 at 15:16
3

If you want one random row from the query:

    <cfset start = randRange(1, Test.recordCount)>
    <cfoutput>
        #Test.name[start]#&nbsp;#Test.email[start]#<br>
    </cfoutput>

No need to loop.

NOTE: It is more efficient to modify the query to get a random row.

How to request a random row in SQL?

Community
  • 1
  • 1
Scott Jibben
  • 2,229
  • 1
  • 14
  • 22
  • I'm not sure how you deduced that he wanted a random row, but kudos on taking that away from this question! – J.T. Oct 28 '14 at 13:39
  • 1
    He had answered his question and it looked like that was what he was trying to do. That answer has been removed so it now looks like I can read minds. ;) – Scott Jibben Oct 29 '14 at 15:40