Random display of the results of the query (no repeat)

First of all, I'm new to ColdFusion, so please forgive me if the answer to this is blantantly obvious, if not totally impossible. Here's my problem.

I queries a database with several hundreds records. The query will return an average of 10-15 records. Then, I want to display 2 of these files at random. I have so much work. The only problem is that every so often, the 2 folders that are displayed are the same record. I need avoid this outcome. The 2 folders should be always different.

Here is a simplified version of my code:

< CFQUERY "queryname" datasource = name = 'Datasourcename' >
SELECT * FROM residential
WHERE ListingOfficeName = 'Steve Realty.
< / CFQUERY >

< cfset randRecordsList = ">
< cfloop from = '1' to '2' index "i" = = >
< cfset randVal = randRange(1,queryname.recordCount) >
< cfset randRecordsList = listAppend (randRecordsList, randVal) >
< / cfloop >

< cfloop list = "" #randRecordsList # "index 'i' = >"
< cfoutput >
#queryName.FieldName1 #.
#queryName.FieldName2
#.
#queryName.FieldName3 # < br >
< / cfoutput >
< / cfloop >

Any help would be appreciated. Thanks in advance.

Here's the general idea. You can handle the specifics.

generate a list of numbers.
maxnum = 15;
numlist = "";
for (i = 1; I lte maxnum; I = i + 1)
numlist = listappend (numlist, i);

randomnums will be two random numbers
RandomNums = "";
x = true;
While (x is true) {}
ThisNum = plageAleatoire (1, maxNum);
If (ListFind (RandomNums, ThisNum) is false)
RandomNums = ListAppend (RandomNums, ThisNum);

If (ListLen (RandomNums) 2)
x = false;
}

Tags: ColdFusion

Similar Questions

  • Filter the table display of the query object (it can a bug in jdev 12)

    Hello:

    I found an error/bug possible in jdeveloper 12 c when I migrate my application of jdev 11g.

    To test this issue, I did the same test request in jdeveloper 11g and jdeveloper 12 c (to avoid to migrate the process).

    Project template

    -Create a display of the query object. Code:

    SELECT 1 CODE, 100 DESCRIPTION
      FROM DUAL
    UNION ALL
    SELECT 2 CODE, 200 DESCRIPTION
      FROM DUAL
    

    -Create a Module of the Application, and then drag this point of view in.

    ViewController project

    -Create a page and drag in the criteria named 'All searchable attributes' of the previous ViewObject as "ADF table filtered.

    -Run the application

    Results:

    On jdeveloper 11g, however it makes the filter above the table box in jdev not 12 c.

    Is this a bug or I need to select something in jdev12c to get the same functionality?

    Yes, known bug 17279781.  It is currently scheduled for a 12.1.4 fix.  If this issue is crucial to you, please file an SR, mentioning the bug number and indicate your reasons for wanting a fix as soon as possible.

    Note there is a solution:

    To work around the problem, you can configure the filter yourself by adding an af:inputText

    facet filter columns and bind the inputText property value to the EL

    #{vs.filterCriteria. }. The page to rerun the filter for

    the column look and work.

    CM.

  • Is it possible to change the number of lines to display in the query of the adf?

    Hello

    is it possible to change the number of lines that appear in a query of the adf that is similar to a form of the adf?

    I need about 5 lines per column rather than display all the fields in a single column to display? Thank you.

    Hello

    What do you mean that it didn't work? Attributes of how you have in the Panel of the query? Maybe you have fewer number than the combination or lines and the properties of the argument maxColumns attributes.

    Try again with

    and see if you are able to get everything under a single column. If you get, play with these two properties to get the desired result.

    Arun-

  • How can I get several hyperlinks to display in the query output?

    I uses two tables to list all a school sport teams. The table of sport lists all team data aggregated by gender. The second table uses the sportID of the first table to associate a team calendar.  The problem is not all the teams do not have a calendar.

    I'm trying to post a link to these teams with schedules. I compare the two tables, the sport and the calendar and a CFIF statement allows to compare the 2 sportIDs in the output to determine the teams who have a schedule.  If the two sportIDs corresponds to a hyperlink is displayed.

    Unfortuanetely, only one link will be displayed, even if there should be three links. Here is my code:

    Table to display aggregated by gender teams

    "< name cfquery ="getSports"datasource =" #application.database # "" >

    Choose between the sexes, team, levels, sportID

    sports

    Group sex, team, levels, sportID

    < / cfquery >

    Table used for the sportID of already created calendars

    < name cfquery = "getID" datasource = "#application.database #" >

    Select sportID

    annexes

    SportID group

    < / cfquery >

    I then compare the sportIDs and if they match, I then display a hyperlink

    "< cfoutput query ="getSports"group 'sex' = >"

    < h1 "> teams #gender < / h1 >"

    < ul >

    < cfoutput >

    < li >

    < cfif getID.sportID EQ getSports.sportID > <a href = "teams.cfm? sportID = #sportID #" >< / cfif >

    #team # < cfif levels GT "" >(#levels#) < / cfif > //levels is used to differentiate the J.V. and Varsity. "." Usage levels not all of the teams

    < cfif getID.sportID EQ getSports.sportID > </ a >< / cfif >

    < /li >

    < / cfoutput >

    < /ul >

    < / cfoutput >

    How can I get the other teams to display their links?

    Thank you gentlemen, since everyone was suggesting an outer join, I took out my trusty Manual of ColdFusion and learn about them. I've added the sum() for the query:

    Select sports.gender, sports.team, sports.levels, sports.sportID, sum (schedules.sportID) AS expected

    sports

    opening hours of the outer join left on sports.sportID = schedules.sportID

    Group of sports.gender, sports.team, sports.levels, sports.sportID

    So add the following to the output:

    And everything works perfectly. Once again, life is beautiful!

  • How to limit the data displayed in the query of the adf

    Hi all
    I have a VO with the query criteria, that I added to the jsf page as Panel query adf with table. There may be particular queires who return the large number of records. Suppose I want to limit the number of records displayed to 10,000. Is this possible with jdeveloper 11g? How can it be done? pls advice.

    Thnx,
    N

    Or, you can go to the View-> Tuning object and set the value to 'back up' to the number 10000.

  • display of the query

    Hi experts,
    can someone tell me how can I view the query that oracle did when its proof of no record has been to extract. I use form 6i.

    Concerning
    Rajat

    Hello

    Have you tried the method of the integrated Get_Block_Property() LAST_QUERY, just after the execute_query?

    François

  • Parent to display in the query of the hierarchy

    Hello
    I want to display the details of the node relative to the hierarchy in the first row.
    For example, if A hierarchy has child A1 and A2, then I want to display A hierarchy in the first line and the A1 and the A2 on the second and third respectively.

    The details of the mother is in the PARENT_ID column and details of the hierarchy is in the HIERARCHY_ID column.

    I need something like:
    Select HIER_ID in the HIERARCHY
    where HIER_ID IS PARENT

    user1080784 wrote:
    For example,.

    HIERARCHY_ID PARENT_ID NAME
    133 100 Trading
    134 133 retail
    135 133 Bank

    In the output, I want details such as:

    ID PID NAME PARENTNAME
    133 100 exchange of Exchange
    134 133 retail trade
    135 133 commercial banking

    user1080784 wrote: because they do not work

    Maybe it works not because you asked the wrong question! I tested it and it works for me. In any case, this is my test;

    SQL> create table HIERARCHY(HIERARCHY_ID number, PARENT_ID number, NAME varchar2(30));
    
    Table created.
    
    SQL> insert into HIERARCHY values (133, 100, 'Trading');
    
    1 row created.
    
    SQL> insert into HIERARCHY values (134, 133, 'Retail');
    
    1 row created.
    
    SQL> insert into HIERARCHY values (135, 133, 'Banking');
    
    1 row created.
    
    SQL> commit;
    
    Commit complete.
    
    SELECT HIERARCHY_id AS ID, PARENT_ID as PID, NAME "NAME",
    NVL((select H1.NAME  from HIERARCHY H1 where H1.HIERARCHY_id = H.PARENT_ID),H.NAME) AS PARENTNAME
      3     FROM HIERARCHY H;
    
         ID       PID NAME                    PARENTNAME
    ---------- ---------- ------------------------------ ------------------------------
           133       100 Trading                    Trading
           134       133 Retail                    Trading
           135       133 Banking                    Trading
    
    SQL> exit
    

    Published by: orawiss on August 8, 2011 18:38

  • Number displayed in the oracle.sql.NUMBER form in the result of the query

    Developer SQL version 3.2.10.09.57 displays numbers like "oracle.sql.NUMBER@66a35419 (the part after @ is not constant and change each time) even for simple count (*) select double."
    At the same time "run the Script (F5)" no indication that the header
    COUNT (*)
    ------------
    and no the query results.

    Hi Andriy,

    The forum search, I see a similar complaint noted against 3.1.07.42. Instruction execution produces the list oracle.sql.NUMBER, probably because of a corrupt installation query results (due to decompress questions, or perhaps no decompression in an empty directory). See the following thread:
    SQLDev 3.1: Number-fields in the tables have "oracle.sql.NUMBER @...". »

    Hope this helps,
    Gary
    SQL development team

  • The query results display help

    Hello

    I'm having a problem with the display of the results of my query result.

    When I cfloop on the results... the part number was released on 3 different ranks... when I want it on a single line, querying multiple tables... and you cannot use the option to group with the cfloop

    This is the query

    <cfquery datasource="wire" name="testss3">
       SELECT a.part AS pparts, a.wireid AS wireidA, a.strnds, a.wt, a.sps1, a.sps2, a.sps3, a.tin, b.slookup AS lid, b.wireid AS wireidB, b.reelid AS reelnmbr, d.reelid AS rlid, d.rname, d.rsku, d.rcost, e.plookupid, e.prctid, e.wireid AS wireidE, f.prctid, f.percentage, g.rsize
       FROM Mpart a, slookupt b, reeltbl d, prctlup e, prct f, spoolsize g
       WHERE a.wireid = b.wireid AND e.prctid = f.prctid AND a.wireid = e.wireid AND b.reelid = d.reelid AND g.spoolSizeid = b.spoolSizeid
       </cfquery>
    <table border="1" border="1">
     <tr>
            <td></td>
            <td bgcolor="#CCCCCC" class="style23">Part No.  </td>
            <td bgcolor="#CCCCCC" class="style23">Wt./Mft.</td>
            <td bgcolor="#CCCCCC" class="style23" colspan="3">Spool Sizes (Cost/ft.)</td>
            <td> </td>
          </tr>
                  
       <cfloop query="testss3"><cfoutput>
         <tr>
            <td></td>
               <td align="left" class="style23">#pparts# @</td>
                <td align="left" class="style23">#wt#</td>
               <td align="left" class="style23">
                #rsize# #rcost#  #wireidA#</cfoutput></cfloop></td>
            <td> </td>
           </tr>       
    </table>
    

    Reference No..M/m/Mft.Sizes in stock waiting (cost/pi)
    ground 10 @.31.431000 2.8000 1
    ground 10 @.31.432500 5.9800 1
    ground 10 @.31.435000 7.3000 1
    400A31.431000 2,8000 2
    400A31.432500 5,9800 2
    400A31.435000 7,3000 2
    8 ground @.50500 2,8000 4
    8 ground @.501000 5,9800 4
    8 ground @.505000 7,3000 4
    8 T @.50500 2,8000 5
    8 T @.501000 5,9800 5
    8 T @.505000 7,3000 5

    the first line should read 10 ground | 31.43. 1000 | 2500 | 5000

    rank 10 t | 31.43. 1000 | 2500 | 5000

    Any help would be appreciated!

    Thank you!

    You must nest CFOUTPUT tags to use the way you want.  One

    outside the loop to get the 'line after line only' and an inner to get all the

    subdetails in this line:

    roughly

  • attempts to display the query results in 2 columns

    I'm trying to change someone elses existing of code to display the results of a query in 2 columns on a web page.

    The result of the existing code can be seen
    here

    Here is the code I am trying to change

    < table width = "95%" border = "0" align = "center" cellpadding = "4" cellspacing = "2" >
    < cfoutput query = "News" StartRowOptional = "" #StartRow_News # "LignesMax =" #MaxRows_News #">"
    < tr align = "center" class = "TEXTnormal" >
    < class nowrap = "style1 TEXTnormal" td >... < table >
    < /tr >
    < class tr = "TEXTnormal" >
    < td > < table width = "100%" border = "0" cellpadding = "0" cellspacing = "0" class = "TEXTnormal" >
    < b >
    < td > < cfif News.ImageNameThumb gt 0 >
    "< a href =" news_view.cfm? recordID = #News.ID #"> < img src =" "uploadedimages / #News.ImageNameThumb #" alt = "#News.ImageCaption #" hspace = "8" hspace = "0" border = "0" align = "left" > < / has >
    < cfelse >

    < / cfif > < table >
    < td > < a href = "" news_view.cfm? recordID = #News.ID # "class ="TEXThighlight"> #News.Title # < /a > - #News.Day #. #News.Month #. #News.Year # < br >"
    #News.Summary # < table >
    < /tr >
    < / table > < table >
    < /tr >
    < / cfoutput >
    < /table >

    I changed the above code to

    < table width = "95%" border = "0" align = "center" cellpadding = "4" cellspacing = "2" >
    < cfset LoopEndRow = CEILING(#EndRow_News#/2) >
    < cfloop
    index = "row".
    from = "#StartRow_News #
    to = "#LoopEndRow #
    step = "1" >
    < class tr = "TEXTnormal" >
    < cfset breaker = 0 >
    < cfloop
    index = "column".
    from = '0 '.
    to = '2 '.
    step = "1" >
    < cfoutput query = "News1" StartRowOptional = "" #StartRow_News # "LignesMax =" #MaxRows_News #">"
    < td width = "50%" >
    < table width = "100%" border = "0" cellpadding = "0" cellspacing = "0" class = "TEXTnormal" >
    < b >
    < td > < cfif News1.ImageNameThumb gt 0 >
    "< a href =" news_view.cfm? recordID = #News1.ID #"> < img src =" "uploadedimages / #News1.ImageNameThumb #" alt = "#News1.ImageCaption #" hspace = "8" hspace = "0" border = "0" align = "left" > < / has >
    < cfelse >

    < / cfif > < table >
    < td > < a href = "" news_view.cfm? recordID = #News1.ID # "class ="TEXThighlight"> #News1.Title # < /a > - #News1.Day #. #News1.Month #. #News1.Year # < br >"
    #News1.Summary # < table >
    < /tr >
    < / table > < table >
    < cfset breaker breaker + 1 = >
    < cfif breaker EQUAL 2 >
    < cfbreak >
    < / cfif >
    < / cfoutput >
    < / cfloop >
    < /tr >
    < / cfloop >
    < /table >

    The results of this code change can be see here

    as you can see what I did gives the number of columns (2)
    and the correct number of lines for the amount of data (3)
    However, each line shows the first 2 pieces of data returned by the query

    Can I change the output query so that it returns the data SET by the amount of data already out items?
    If so, how?



    #data #.




    closing tags

  • How to get SQL Developer 4.1 to display the query result?

    SQL DEV 4.0.3.16.84 execution of a SELECT statement is stored in a .sql file causes the window of the query result of pop-up indicating the result of a SELECT statement.  SQL DEV 4.1 is not to do so.

    Oops on my part; my SQL formatting has been the root cause.  I got used to insert split without any character of comment lines in front of them.  For example:

    ==================================================

    Select funny business;

    The foregoing indicates the behavior described.

    --==================================================

    Select funny business;

    With the dash double comment shows, the SQL works very well.

    This is different than previous versions of SQL Developer, but is probably better functionality.  I'll try to mark it as answered, but anyone with the admin should certainly do so if I can't.

  • 3.1EA1: does not display the query results

    The results of any query I have run in 3.1EA1 do not show in the results of the query tab. When I run sqldeveloper.exe from the command prompt, there are no errors. Sqldeveloper 3.0 is very good.

    Oracle database: 10.2.0.4.0
    Java version: 1.6.0_26
    Operating system: Windows XP sp3 Prod

    This seems to be related to read/write to the history of SQL.
    You can see the question after a
    delete your SQL history
    or if you do not want to keep your history - zip C:\Documents and Settings\\Application Data\SQL Developer\SqlHistory folder before you delete it.

    Let me know.
    -Rambeau

  • 3.0EA1: display of several results of the query in a spreadsheet

    Hello Forum,
    just after starting SQL Developer 3.0EA1 for the first time, I had a new tab for each SQL query result I entered in the worksheet. This is a great feature!
    But now I can not reproduce this behavior. All SQLs put their results into a single query result tab. The last of them wins.
    I have not found a preference setting to return several results of the query again.
    Did I miss something?
    I'm running on Windows XP and updated the parameters of 2.1.1.64. Perhaps that explains the rescue of the old behavior afer restart SQL Developer.
    I connect to Oracle 10.2.0.5 if it matters.

    Kind regards
    dhalek

    Preferences - Database - spreadsheet - automatically freeze the tabs of the result, or red pine under the result tabs button themselves.

    Have fun
    K.

  • Display of the results of the query with the column names unknown

    I use this code to grab the headers of columns in a select * statement. (I never know what table is queried out of 12 000 or more.) I want to make a loop on the column headers, then the query results in a web page table.

    < cfoutput >
    < cfset colHeaderNames = ArrayToList (recordset1.getColumnList ()) / >
    #colHeaderNames #.
    < / cfoutput >

    Is there a similar method or suggestions for the release of the results of the query - now that I know the column headings?

    If I understand correctly, you can do something like the code below.

  • Display the result of a query in 3 columns

    Hello

    I have a query with n records. Now, I want to display all the records in a HTML page into 3 columns. I don't have any idea on how to do it!

    What I would like is (assuming I have 9 entries in my query):

    < div id = "column1" >
    viewing records 1 to 3
    < / div >

    < div id = "column2" >
    view records of 4-6
    < / div >

    < div id = "Column3" >
    view records 7-9
    < / div >

    Someone has a short solution or at least a link to a sloution. I can't find anything big yet...

    Thanks and greetings

    Hello

    I found a solution that works very well - unfortunately I don't really understand it :-)

    Thank you for your contributions!

Maybe you are looking for

  • PBS Sign - in does not work

    Try to connect at the PBS site. I get a box that allows me to connect with Facebook, Google + or PBS by clicking on the logo of the service I want to use.Unfortunately, I can click on any one of them all day and nothing happens.Clicking on them works

  • Download issues of FTP files using safari 9.1

    Using other browsers (chrome and firefox) I can click on a link that will download a file FTP on my macbook pro. In safari 9.1 however I get an "unknown error" (NSURLErrorDomain: - 1). The link that I use is ftp://ftp.ebi.ac.uk/pub/databases/genename

  • How to upgrade Java

    Hello The foregoing ask download Java script. Is this save to allow. SEE YOU SOON original title: Sun Microsystems Inc.

  • Open a session in that no computer control problems can not you as an administrator

    can not connect as administrator can not remember my password also won't let me reset my password or change it in the parent control or all controls advanced without having to ask a system administrator. I think that something else is controlling my

  • Runtime error Vista Ultimate Upgrade

    I recently bought and downloaded Vista Ultimate Upgrade of the site ultimate steal Microsoft.  I downloaded all three components: X 14 - 63453.exe, install.wim and boot.wim.  I am running Windows XP Media Center edition 2005 with Service Pack 3 insta