...">

How can I get a specific row in a query variable using ColdFusion?

Take the following query example:

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

Suppose the query "Test" returns 10 rows. I want to show one line at a time.

Note. I do not want to modify the SQL statement.

+5
source share
2 answers

If you need one random line from the query:

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

No need for a loop.

NOTE. More efficient query modification to get a random string.

How to query random string in SQL?

+3
source

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

+6
source

Source: https://habr.com/ru/post/1205603/


All Articles