Display Random Record

Morning all
Just a quick one.
How do I display a random record in DW?
I have a MySQL statement which is:
SELECT * FROM
tablename ORDER BY RAND() LIMIT 0,
number of records to display
The error message I get is:
'Syntax error (missing operator) in query expression RAND()
LIMIT 0'
If I alter 'RAND()' to 'RND()', I still get the error. If I
remove the '0' I still get the error.
Any ideas how to make this work?
I'm using Access BTW.
Regards
Martin

Tell your SQL statement what to RAND - right now it doesn't
know how to
randomize it, by what field.
"Pantyboy" <[email protected]> wrote in
message
news:ef0and$r7g$[email protected]..
> Morning all
>
> Just a quick one.
>
> How do I display a random record in DW?
>
> I have a MySQL statement which is:
>
> SELECT * FROM
tablename ORDER BY RAND() LIMIT 0,
number of
> records to
> display
>
> The error message I get is:
>
> 'Syntax error (missing operator) in query expression
RAND() LIMIT 0'
>
> If I alter 'RAND()' to 'RND()', I still get the error.
If I remove the '0'
> I
> still get the error.
>
> Any ideas how to make this work?
>
> I'm using Access BTW.
>
> Regards
>
> Martin
>

Similar Messages

  • Display random records

    Hi guys,
    Is there an easy way to display a random record from an XML
    file? Current code:
    HEAD
    <script type="text/javascript">
    <!--
    var dsPower = new Spry.Data.XMLDataSet("broadband.xml",
    "software/product");
    //-->
    </script>
    BODY
    <div spry:region="dsPower">{product_name}</div>
    What i want to happen is when the page is loaded (and/or
    reloaded) i want the {product_name} to randomly display any one of
    my ten product names. I presume it requires use of {ds_RowID} and
    some JavaScript, but am unsure of where to begin.
    Thanks in advance for any help.

    nevermind people, i figured it out already. please close this topic.

  • Random Record Display

    Can someone tell me how to display a random record from a database? I want to use it on my site to show a "review"... am able to do it in ASP but not sure how to in JSP.
    Any advice is gratefully received.
    M

    ok man
    you can put all object that you get it form DB in not
    sorted contener as HashMAP. okYeah, then to further randomize it, you can use a Random Number to lookup in that HashMap. ;) Sounds interesting.
    Annie.

  • How can I select the random records in u201Cstep loopu201D.

    Hi, Experts,
    I am using step loop to display the data on screen now I want to select the random records from this step loop display. Like 1st 3rd or 5th record, is there any way to select the records,
    like I did in Table control there was a filed in internal table named marked char length 1, I gave this field name in u201Cw/ SelColumnu201D it fill that field with u2018Xu2019 from where I can get the info about the selected records, in this way I can easily perform the operation on that internal table with the help of that marked field.
    Is there any way to select the records in step loop too ?
    Kind Regards,
    Faisal

    thanks for replay shwetali,
    but i just gave you example of random records with 1st 3rd and 5th my goal is not select only these records. i want to select the random mean any records from the step loop display.
    like we can select from the table control. and when select any record it place 'X' in the given internal table field.
    Thanks and kind Regards,
    Faisal

  • Dynamic Table with Random Records

    What I am trying to do is select random records from a table
    and display them in a dynamic table with max columns set to 3 and
    the 4th record to be on a new row. Below is what I have right now
    and it works to randomly pick records but has no function to set
    columns in a table. If there is an easier way feel free to let me
    know. I have tried various ways to do this but none seem to work.
    <CFQUERY NAME="getItems" DATASOURCE="absi">
    SELECT catfit.*, modcats.*, prodmat.*, prod.* FROM catfit,
    modcats,
    prodmat, prod WHERE prodmat.prodid=catfit.prodid And
    catfit.catid=modcats.catid
    ORDER BY modl ASC </cfquery>
    <cfif getItems.recordCount>
    <cfset showNum = 3>
    <cfif showNum gt getItems.recordCount>
    <cfset showNum = getItems.recordCount>
    </cfif>
    <cfset itemList = "">
    <cfloop from="1" to="#getItems.recordCount#"
    index="i">
    <cfset itemList = ListAppend(itemList, i)>
    </cfloop>
    <cfset randomItems = "">
    <cfset itemCount = ListLen(itemList)>
    <cfloop from="1" to="#itemCount#" index="i">
    <cfset random = ListGetAt(itemList, RandRange(1,
    itemCount))>
    <cfset randomItems = ListAppend(randomItems, random)>
    <cfset itemList = ListDeleteAt(itemList,
    ListFind(itemList, random))>
    <cfset itemCount = ListLen(itemList)>
    </cfloop>
    <cfloop from="1" to="#showNum#" index="i">
    <cfoutput>
    <table width="205" border="0" align="left"
    cellpadding="0" cellspacing="0">
    <tr>
    <td width="235" height="116"> <div
    align="center"><img
    src="../Products/ProductPictures/#getitems.pic[ListGetAt(randomItems,
    i)]#" width="100"></div></td>
    </tr>
    <tr>
    <td
    class="ProdTitle">#getitems.brand[ListGetAt(randomItems,
    i)]# #getitems.modl[ListGetAt(randomItems, i)]#</td>
    </tr>
    <tr>
    <td
    class="paragraph">$#getitems.prc[ListGetAt(randomItems,
    i)]#</td>
    </tr>
    <tr>
    <td><A
    href="../Products/details.cfm?prodid=#getItems.prodid[ListGetAt(randomItems,
    i)]#" class="linkcontact">more
    info</a></td>
    </tr>
    <tr>
    <td> </td>
    </tr>
    </table>
    </cfoutput>
    </cfloop>
    </cfif>

    To start a new row after 3 records, do something like this.
    <table>
    <tr>
    <cfoutput query="something">
    <td>#data#<td>
    <cfif currentrow mod 3 is 0>
    </tr><tr>
    </cfoutput>
    </tr>
    </table>
    You should also know that your approach is very inefficient
    in that you are bringing in to cold fusion more data than you need.
    First of all you are selecting every field from 3 tables when you
    don't appear to be using all of them. Second, you are selecting
    every record and you only want to use 3. There are better ways out
    there, but they are db specific and you did not say what you are
    using.

  • Random record return

    I have a DB of sites that I need to query and pull in 5
    records that are to be displayed in a random order.
    I can limit the records but I'm struggling with displaying
    them in a random order.
    Any ideas?

    We're using MySQL as the DB and to clarify I need to pull in
    5 random records in a random order.
    I've just been emailed the answer by a friend so I'llpost it
    up here.
    "SELECT *
    FROM tablename
    WHERE somefield='something'
    ORDER BY RAND() LIMIT 5"
    Seems to work fine to me.

  • Random record for ASP

    I would like to have a section on my ASP page to generate a
    random record that pulls from my database. So that each time the
    page is opened/refreshed, a different record is displayed.
    Any ideas?

    "Biggest Dave" <[email protected]> wrote in
    message
    news:e2nn6n$83e$[email protected]..
    >I would like to have a section on my ASP page to generate
    a random record
    >that pulls from my database. So that each time the page
    is
    >opened/refreshed, a different record is displayed.
    >
    > Any ideas?
    Yes.
    Of course, since I don't know what database you're using, any
    or all of
    those ideas could be useless.

  • Random Record + Update

    Looking to create a random record repeat region where the
    random records being pulled updates a hit count. i.e. a simple
    banner rotator that counts how many times it's displayed. not all
    banners being rotated are in one folder... they are simply accounts
    designated as being featured. I tried the order by rand() limit
    5... error. changed to just rand() and that worked... but how do I
    update a file based on that?

    darrel wrote:
    >> i tried the code you provided, the 2 question
    marks... but that didn't seem
    >> to do it either. anyone else have any ideas on how
    to update a hit counter
    >> based on the random record recordset?
    >
    > Instead of being a smart-***, how about actually either
    a) quoting the
    > original question or b) repeating the question.
    >
    > Anyone that's going to be of any help to you uses the
    newsgroup interface,
    > not the crappy web forum, so when you reply to a
    question that's several
    > weeks/months old, we don't see the original post.
    >
    > So, as such, all we saw was your silly question mark.
    I use a newsreader and saw the entire thread as if it was a
    new one.
    There was 3 days between the original posts and his question
    mark. Maybe
    a question mark wasn't the right way to get more attention to
    the post...
    Steve

  • Random Record from a Query

    I have a page on my site that displays certain information in
    kind of a "feature" section, where it needs to query the database
    based on certain criteria and then display the data for just one of
    the records. The record should be different each time the page
    loads. So, if my query has 10 or 20 records, I just want to select
    one of them randomly and disply its data. What would be the best
    way to code such a scenario?
    Many thanks.

    first, a statement that contains "The record
    should be different each time the page loads" and "select one
    of them
    randomly and display its data" is a bit of a contradiction:
    you either
    display a random record or you control which record to
    display to make
    sure each page load displays a different one.
    if you just want a random record displayed (which means same
    record may
    be displayed on subsequent page loads) then how to do it
    depends on
    which database you are using, as cfSearching pointed out.
    here's a great place to look to sql statements for this for
    various db
    systems:
    http://www.petefreitag.com/item/466.cfm
    if you want to display a different record each page load, you
    need to
    keep track which records have already been displayed
    previously and
    display the next one in sequence. you could do this by
    storing the list
    of record ids in an application-scope variable, displaying
    the record
    with the first id and removing that id from the list of ids.
    when the
    list is empty, query the db for record ids again and make a
    list anew.
    hth
    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/

  • How can I display all records as a end user?

    I am applying for jobs with the state and every week they publish a list of new positions that have just been posted on the following link: https://forms.spb.ca.gov/bulletins/weekly.cfm
    and also at http://jobs.spb.ca.gov/wvpos/search_p_ejv.cfm?classcode=5393&criteria=associate%20governme ntal
    It is a .cfm but only displays 15 records at a time, I was wondering if there is a tag or way to have it display all 300 something records at once?  My ultimate goal is to get just the full table into a excel spreadsheet while retaining the HTML formatting so the links still work.
    My thought is that the state has set it up this way to only display a set number of records at a time, the data is not private or protected, I am simply seeking a easier way to access it in aggregate.
    Thank you in advance for your suggestions and help!

    I think your best hope is to ask the author of the CFM whether they provide any web service that can get you that data when you call it.  like.
    https://forms.spb.ca.gov/webservice.cfc?method=getJobsPostings&key={key_goes_here}
    There's a chance they may be regulating performance on the resultset, and don't want to return that many records at a time, pagination or not.

  • Display all records from 4 select list

    Hi,
    trying to associate 4 select list where i could display all records from a list linked to an other list.
    1./ Created an item for each select list
    P1_employee_name
    P1_departments
    P1_employee_type
    P1_locations
    2./Set both null and default values to '-1' for each item
    3./Associated these items to source columns in the Region:
    where employee_name=:P1_employee_name
    or :P1_employee_name ='-1'
    and departments=:P1_departments
    or :P1_departments ='-1'
    and ......
    When running the report, couldn't display all records from a given list associated to an other list.
    e.g: Display all emp and type of emp for sales dept in Paris.
    Thks for your help

    I believe the issue is that you need to group your predicates such as:
    where (employee_name=:P1_employee_name
    or :P1_employee_name ='-1')
    and
    (departments=:P1_departments
    or :P1_departments ='-1')
    Also, if you are not already using the "select list with submit" type items, these work great for this case as the page will be submitted when the user changes the value of employeenam and the report will then reflect this change.

  • Form does not display all records from table

    Hi guys
    I modified one form that was based on a signle DB table. I removed certain fields from the table and added some extra fields to that table. Then based on the new table I also modified the form and removed the text items related to old fields in the table and added new text items pointing to the new fields now. II have checked all the new items properties and they have don't seem to be wrong or so. But now the problem is the form does not display all the records from the table. before it used to display all records from the table when qureied but not now. It only certain records from the table containing all new data and also old data but the form does not display other records though I don't see any obvious discrepancy. Remember that the before doing the modifications, I have table back for the old, created another table that contained new records for the new fields, and then I inserted the old records and updated the new table data in the new table with these new table values. So this way I have got my new table. Could someone help why the new modified form fails to display all records from the new table updated table though it display some of them successfully.
    Any help will be appreciated.
    Thanks

    hi
    Set the block property of "Query All Records" to "YES"
    hope it will work.
    Faisal

  • Report for displaying info record scale prices

    Hi all,
    Can any one provide me the sample code for a report  displaying info record scale prices.
    Thanks,
    Suresh

    Check t.code MEKP.

  • Report- not displaying some records in the report

    I have a query say q1 based on the query value. I am getting place holder colums obtained from a procedure. based on one of the place holder columns i want to display the data say i have place holder column err_ind if it y. i don't want to display the record in report.
    how can i do it ? ur help is much appreciated.

    Hi Praveen,
    Thanks for the response.
    Actually i did debug the program with the help of our technical guys but found nothing wrong in both the quality and the production system. We compared the program in both the systems and it seems to be same. I am exploring this issue. Will update the findings here.
    In case anyone has any suggestion please do suggest.
    Regards,
    Gokul

  • Display one record at a time

    i am trying to display one record from my database on my jsp page per time using next and previous buttons to navigate. I have tried to implement this by putting the resultset in a vector and then tried to tried to dispaly data with no success.Please somebody help ,i been at this for two days with no success.Could someone give a concreate example to guide me

    Please post all code, i dont know how to put my resultset in a vector or arraylist.
    I need a First Previous next and Last link in asp it is called recordset paging or recordset navigation.
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <%@ include file="Connections/connEvents.jsp" %>
    <%
    int index = 0; //or wherever you wish to start
    if((String s = request.getParameter("index")) != null)
    index = Integer.parseInt(s);
    %>
    <%
    Driver DriverrsEvents = (Driver)Class.forName(connEvents_DRIVER).newInstance();
    Connection ConnrsEvents = DriverManager.getConnection(connEvents_STRING,connEvents_USERNAME,connEvents_PASSWORD);
    //PreparedStatement StatementrsEvents = ConnrsEvents.prepareStatement("SELECT * FROM hog_evenementen", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
    //StatementrsEvents.setFetchSize(10);
    //ResultSet rsEvents = StatementrsEvents.executeQuery();
    PreparedStatement StatementrsEvents = ConnrsEvents.prepareStatement("SELECT * FROM hog_evenementen");
    ResultSet rsEvents = StatementrsEvents.executeQuery();
    %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>HD - Evenementen-beheer</title>
    <style type="text/css">
    <!--
    body {
         background-color: #333333;
    -->
    </style></head>
    <script>
    function post(actValue)
    document.MyForm.action.value = actValue ;
    document.MyForm.submit() ;
    </script>
    <body>
    <table width="60%" border="0" align="center" cellpadding="0" cellspacing="0" class="">
    <tr>
    <td><table width="100%" class="" border="0" cellpadding="6" cellspacing="0">
    <tr>
    <td width="175" align="center" valign="bottom" bgcolor="#FF6600" class="">Evenementen-beheer</td>
    <td bgcolor="#333333" class=""><span class=""><span class="formField">
    </span></span></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="6">
    <tr bgcolor="#61ABD0" class="verdana10zwart">
    <td width="4"> </td>
    <td width="512" height="29"> <span class="">Evenementenoverzicht</span></td>
    </tr>
    <tr bgcolor="#61ABD0" class="">
    <td> </td>
    <td><table width="100%" border="0" align="center" cellpadding="6" cellspacing="0">
    <tr class="">
    <td width="252" class="smallText">record 1 van 1 etc moet hier komen <br></td>
    <td width="231" align="left" class="smallText"><table width="50%" border="0" align="center">
    <tr>
    <td width="23%" align="center"> Firs </td>
    <td width="23%" align="center"> <a href="index.jsp?index=<%= (index-10)%>">Previous</a></td>
    <td width="23%" align="center"><a href="index.jsp?index=<%= (index+10)%>">Next</a></td>
    <td width="23%" align="center">Last</td>
    </tr>
    </table>
    <br>
    </td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <td>Thema</td>
    <td>Datum</td>
    </tr>
                   <%
                   int rowCount = 0;
                   while(rsEvents.next() && rowCount < 10) {
              rowCount++;
                   %>
    <tr>
    <td><a href="event_crud.jsp?ID=<%= rsEvents.getObject(ID")%">"><%= rsEvents.getObject("thema")%></a></td>
    <td width="231"><%= rsEvents.getObject("datum")%></td>
    </tr>
                   <% } %>
    </table></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td bgcolor="#CCCCCC"><form action="event_frm_process.jsp" METHOD="POST" name="MyForm" id="MyForm">
    <table width="100%" border="0" cellpadding="6" cellspacing="0" class="verdana10zwart">
    <tr bgcolor="#CCCCCC">
    <td width="9"> </td>
    <td colspan="2"><span class="kop1"><br>
    Evenement toevoegen </span><span class="formField"><br>
    </span><br>
    <span class="formField"> </span></td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <td width="9"> </td>
    <td width="107" class="downBorder">Thema:</td>
    <td width="383" class="downBorder"><input name="thema" type="text" id="thema"></td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <td width="9"> </td>
    <td class="downBorder">Omschrijving:</td>
    <td class="downBorder"><textarea name="omschrijving" cols="40" rows="10" id="omschrijving"></textarea>
                   </td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <td width="9"> </td>
    <td class="downBorder">Datum:</td>
    <td class="downBorder"><input name="datum" type="text" id="datum"></td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <td width="9"> </td>
    <td class="downBorder">Tijd:</td>
    <td class="downBorder"><input name="tijd" type="text" id="tijd"></td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <td width="9"> </td>
    <td class="downBorder">Lokatie:</td>
    <td class="downBorder"><input name="lokatie" type="text" id="lokatie"></td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <td width="9"> </td>
    <td class="downBorder">Plaatje:</td>
    <td class="downBorder"><input name="plaatje" type="text" id="plaatje"></td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <td width="9"> </td>
    <td class="downBorder"> </td>
    <td class="downBorder"><input name="insert" type="button" id="insert" onClick="post('insert');return false;" value="Evenement toevoegen"></td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <td width="9"> </td>
    <td>
                   <input name="action" type="hidden" class="" id="action" value="">
    <% while(rsEvents.next()){ %>
                   <input name="ID" type="hidden" class="" id="ID" value="<%=rsEvents.getString("ID")%>">
                   <%
                   %>
                   </td>
    <td> </td>
    </tr>
    </table>
    </form></td>
    </tr>
    </table>
    </body>
    </html>
    <%
    rsEvents.close();
    StatementrsEvents.close();
    ConnrsEvents.close();
    %></a>

Maybe you are looking for

  • How do I print a list of messages in an Inbox?

    I have 4 e-mail accounts and have a separate Inbox for each account. Is there a way to print a list of the messages in a particular Inbox? I'm just looking for a simple list that I can open in Word or Excel with the From, Subject and Received or Sent

  • Empty response HWC

    Hi, We are working on HWC application with rest webservices MBO approach. Getting empty response in hdc.processDataMessage hwc.processDataMessage = function (incomingDataMessageValue) {   alert(JSON.stringify(incomingDataMessageValue)+"in process dat

  • Is there a way to register non-speaking characters as characters?

    Last question for today, I promise: My script has a lot of non-speaking characters. I would like them to show up on the character reports. Obviously, whenever I highlight their names in the script and set them to "characters", their names are centere

  • How to rotate 2 3D paths?

    Hi, I have A.I CS6 i was wondering if two different shapes could rotate using the same center of z-axis rotation.. It ended that the only way to do it is that both objects have to share the same extruded properties.... If i create both objects with i

  • Can I use Migration Assistant from Snow Leopard to Mountain Lion?

    I've done a clean install of Mountain Lion 10.8.1 - a 'test' installation on a new clean partition on my main HD. It boots fine and runs fine. But Mountain Lion's Migration Assistant does not recognise my external HDD which contains a bootable clone