Limiting Returned Data To Last X Fields With Sql

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > Others

Limiting Returned Data To Last X Fields With Sql

zeeman48
Hello, I'm currently developing a social-networking site in ColdFusion and several aspects of the site require me to return a limited number of records for display (e.g. displaying the last 3 news items in the left-hand column on the front page, etc.).
I currently only have a small SQL "cheet sheet" and what my ColdFusion reference book tells me, and I cannot find anything anywhere about limiting the data returned from a SELECT statement to the last X number of records.

Any help is appreciated!
Thanks,
zeeman48

Reply

jlhaslip
Have a look here: http://dev.mysql.com/doc/refman/5.0/en/query-speed.html

Reply

rvalkass
The simplest way is to just tag LIMIT = X onto the end of your query, with X representing the number of rows you want to return. However, this will return them in the order they appear in the database. Normally you want to include a statement in the SQL command to order the data according to a set column. For the news example here, order them by descending for the date or time column, then limit the query to 3 results.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Similar Topics

Keywords : limiting, returned, data, x, fields, sql

  1. Create Dynamic Html/php Pages Using Simple Vb.net Code
    Taking your application data, and creating a webpage for others to vie (1)
  2. Need Advice On Setting Up Mysql Database.
    I have a huge amount of daily data updates to be inserted. (4)
    First of all, to get the idea of what I am trying to achieve here, please have a look at my
    idea thread, entitled Idea For Using A Cron Job To Grab Daily Travian Map.sql Updates . This gives
    a prelude to the project, what it is for, what it is supposed to do, etc. Now, what I need is
    specific advice on setting up the mySQL database(s) to implement this idea. There is a useful FAQ
    file for how to make use of the map.sql data located on the help.travian.com website, which also
    gives an example of the CREATE TABLE instruction that matches the data in the map.sql fi....
  3. Need Help With My Database [resolved]
    retrive data as a link (6)
    This is the situation: I have a database where you can add bands ( theire albums, genre other
    info) For the album part they can add for each album the songs. So what do i want: When i show
    the results there only shoul display the bandname which should be a link to the more detailed info
    like albums biography etc. How do I do that. Is there a name for this and are there any
    tutorials. thx in advance....
  4. Very Disappointed With Data Center Migration
    What do you think? (9)
    I am hopping mad. I have had nothing but grief since Trap 17 moved their Data Center (DC).
    My site has been down more time than it has been up. I have had to contact Live Support at Xisto 4
    times now in the last month. This is ridiculous. They fix things, it lasts a few days and my site
    is down again. I am at my wits end. I have been told my support to contact Shree. I have
    already communicated with him and he told me that things were solved 6/16, then whatever happened,
    my site was lost completely and had to be restored from their backup. My whole acc....
  5. 1 Terabyte Of Data On A Thumb Drive
    Yes, a whole terabyte! (8)
    Source Seriously, this is innovative. I can't wait for them to produce these...though you know
    the sellers are gonna jack the hell out of the price. In any case, I can only wonder what this will
    mean for desk top and laptop computers. I mean if they can fit a terabyte in a thumb drive with this
    technology, think of how much they can fit into a normal comp. Think of how much music that would
    hold....how many games you could fit.....the possibilities are almost literally endless.....
  6. Eraser - Erase Your Data Permanently! For Free
    A must have software (7)
    When you delete file and empty recycle bin (Windows), it doesn't actually gone permanently!
    Many software can be used to recover those deleted files. Now think and imagine, you've deleted
    your personal file or something then someone recover and steal it. Don't worry, Eraser will come
    in handy What does it do? It delete files permanently! Nothing and noone can recover it. You
    can make previously deleted files not recoverable too by using Erase unused disk space feature. (if
    you want to sell your harddisk, use this) How can? It uses the patterns used ....
  7. Effective Search Over Web
    tips for dummies in the search fields (0)
    keywords it is very important one information can be segregated easily and quickly over web
    otherwise search engine is compact world for eg searching books related to specific subject let
    take microbiology information required on cholera searching steps step 1 we know the subject
    which is primary keyword :"microbiology" step 2 it is bacteria which is considered as secondary
    keyword step 3 the bacterium causes diarrhoea so the family is enterobacteriacae finally the
    specific word lets take on a toxin created by cholera so by following these protocol we can get....
  8. Getting Started With Mysql
    creating tables and insert data into them. (2)
    Hi in this tutorial you will learn how to create tables and insert items into them. First steps are
    to create the database - go into your cpanel and mysql databases, from there make an account and a
    database and then attach them together with all priviliges, call the database test and the account
    admin, with the pw as pass - or any other password. We need to connect to the database so first in
    your php file (probably named index.php) - this is how to do it. CODE
    mysql_connect("localhost", "admin", "pass") or
    die(mysql_error(&....
  9. Tropical Stream And Wheat Fields
    Made with Vue 6 (2)
    Here are a few of the renders I am pretty happy about. Wheat Fields Tropical Stream (For
    the full sizes, I will upload a zip if anyone wants) Hope you like them /smile.gif"
    style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Took around 20 minutes each
    with Vue xStream 6....
  10. What Value Would I Use To Insert This Data?
    Help on insertion of data to database? (4)
    I am learning slowly but surely and I know some of you probably getting tired of my questions. ^^;;
    However, I believe one can not learn without asking questions. So.. if I get too bothersome.. just
    point me to some books or something. lol XD // Make a MySQL Connection mysql_connect("localhost",
    "name", "password") or die(mysql_error()); mysql_select_db("at2927_abq") or die(mysql_error()); //
    Insert a row of information into the table "example" mysql_query("INSERT INTO members (pasture)
    VALUES('Timmy Mellowman', '23' ) ") or die(mysql_error()); ....
  11. What Is The Best Software
    what is the best software to recovery the data (5)
    Hi any one can tell me what is the best software to recovery the data ....
  12. Data On My Subdomain/webspace Vanished
    I need quick response!!! (1)
    Okey, I noticed that there is no data on http://rvovk.computinghost.com/ I have had htaccess
    redirect 301 files on computinghost server to point it to http://godbacrnomelj.rvovk.com/ Some
    time in the past happened that this redirection is not functional anymore and also I can't get
    logged onto my server. My email robertv@najdi.si was deleted, which I used for computinghost.com
    registration, due to changing from free email service to paid email service, so I can't get nor
    my new password nor information about server changes that happened on computinghost.c....
  13. Treating .csv Files As Database Data
    Showing .CSV data on a web page (2)
    I use a nice program (which I helped to beta test) called ' Simfatic Forms ' to generate
    forms on web pages. The only problem is that it does not (yet) support MySQL databases, it saves the
    form data as a .CSV file. Now I was wondering if you can do the same with a .CSV file as you do
    with a MySQL databse, ie. displaying the data in that file on a web page which adjusts automatically
    as data are added to the file. To clarify: eg. if I make a form to sign a petition online, the data
    are saved to a .CSV file every time someone fills in the form, is it now possibl....
  14. Free Web Hosting: (caius) [manual Data Input?] [denied]
    Website Upgrade: <era.us.tp> (1)
    I couldn't get the automatic hosting submission tool to operate on my pc due to a flaw on the
    local network I am using. Despite the fact that my computer would probably operate the site if I
    waited even 1/2 hour, I decided to delay no further. By my understanding of the main site page
    (http://www.trap17.com/forums/index.php?) the package 2 or "account upgrade" could be started as an
    initial package. I wish to set upmy site with trap17 as a webhost because I enjoy the community and
    wish to grow my site from it, hopefully staying. Domain or Subdomain Name: era.us.t....
  15. Php + Mysql Question!
    While inserting data into MySQL, how can I know if the data I'm in (4)
    Basically, I want to know if the Data I'm inserting through a Form is already there or not. Sort
    of a Username registration page. I have this, but it doesn't appear to work... CODE
    $result = mysql_query("SELECT * FROM users WHERE
    username='$username'"); if($result == 1)     {     echo
    '<h1>ERROR!</h1>The username you have chosen already exists!';     }
    ....
  16. Data Structure -- Queue -- Implement Using Stack
    (1)
    Implement a Queue using a stack. No restriction on space complexity. One possible Solutions a
    costly procedure... 1. Use a temp stack 2. Insertion into queue - Push the element into the
    original stack 3. Deletion from queue - Pop all the elements from stack into a temp stack
    - pop out the first element from the temp stack - pop all the remaining elements back to the
    original stack What is a queue? QUOTE A queue is a particular kind of collection in which
    the entities in the collection are kept in order and the principal (or only) operation....
  17. Data Recovery Program..help!
    (6)
    I have a WD hard drive with 2 partitions. One for OS and the other for data. I have accidently
    formatted my 2nd partition and all the data in there is gone. Is there any good program for data
    recovering? ....
  18. Data Structures -- String -- Palindrome
    Check if a string is a palindrome... (5)
    Write an algorithm to check whether a given string is palindrome or not in time complexity O(n)
    What is a palindrome?? QUOTE A palindrome is a word, phrase, number or other sequence of units
    that has the property of reading the same in either direction (the adjustment of punctuation and
    spaces between words is generally permitted). Composing literature in palindromes is an example of
    constrained writing. The word "palindrome" was coined from Greek roots palin
    (πάλιν; "back") and dromos (δρóμος; "way,
    direction") by....
  19. Data Structures -- Linked List -- Reverse
    Reverse a linked list (5)
    Give an algorithm to reverse a linked list with a time complexity of O(n) and minimal space
    complexity. What is a linked list? Search trap17.com. i Have already answered this question in
    one of my older questions. Solution 1 Here is one simple solution... CODE Void
    ReverseList(node* head) {     node *temp,*current,*result;     temp=null;     result=null;
        current=head;     while(current!=null)     {         temp=current->next;
            current->next=result;         result=current;         current=temp;     }   
    head=result; ....
  20. Data Structures -- Linked List
    Find the nth last element in linked list. (9)
    Given a linked list, find the 5th last element with Time complexity O(n) and minimal space
    complexity. Note: If you know the answer and if you feel it is simple also please post the
    answers so that others will come to know about the answers. What is a linked list?? /* this is for
    your further reference and reading */ QUOTE In computer science, a linked list is one of the
    fundamental data structures, and can be used to implement other data structures. It consists of a
    sequence of nodes, each containing arbitrary data fields and one or two references ("links") po....
  21. Loading File Into Blob Fields To Mysql
    (1)
    Hi all! does any know how to load file into blob filed by sql script?....
  22. Data Recovery Software
    tools for restoring deleted/formated hard drive, usb and memory (3)
    Guys pls post here if you have some new software... Short, brief and one liner are considered spam
    in our forum. Post with quality contribution. ....
  23. Data Base For A War Game
    need data base (5)
    Hey, any one can give me a sight to get databases for war games, a database that could include units
    hp,speed,power and similar things. And if you can how can i put the numbers I want as hp,speed and
    other things as i want. ....
  24. How Good Is This Data Cleaning Function?
    (2)
    Hi all, this is my first function and as part of a script and i just want to know a couple of
    things. here is the code for the function: CODE <? function
    clean($dirty_string) { $muddy_string = stripslashes($dirty_string);
    $murky_string = strip_tags($muddy_string); $clean_string =
    htmlentities($murky_string);      }; ?> So the first thing is how secure is
    it? the script this will be used in connects to a database and sends an email so it needs to stop
    SQL injections and any email ab....
  25. Data Can Be Stored On Paper
    Store GB's of electronic data on Paper (31)
    A student has developed a technique to store data on portable paper :-) ....
  26. Get 30 Gb Email For Free
    let us talk about , email system for huge data ! (31)
    Friends here we are talking about largest email, free System http://www.30gigs.com this one is
    good and can handel many file at a time. plz let me know any one having this type of information
    ! Also for small user www.walla.com is good one....
  27. New Tech: Data Transmiting At 2.56 Terabites Per Second!
    Thats like 60 dvd's per second! (11)
    QUOTE Japanese and German researchers have transmitted data over a 160 kilometer link. This
    breaks the old record witch was held at 1.28 terabits per second. This new technology has
    allowed the researches to transfer 2,560,000,000,000 bits per second witch is the equivalent to 60
    dvd's.And this is PER SECOND ...... Just amazing what these people can come up with,
    stuck in a labatatory with copper wire everywhere,... wait more like fiber-optic. -To me this
    shows the progression of technology and speed of witch we will shortly be able to achei....
  28. C Problem: "two Or More Data Types In Declaration"
    also need help with malloc (6)
    What does it mean when I get the error QUOTE two or more data types in declaration of (function
    name) It's almost the exact same as a function I have in another program that compiles and
    works fine. Also, can someone explain malloc or give me a tutorial? Like where and how you use it,
    and if there are any restrictions to where you can use it. Shortened topic title to fix page
    distortion on the home page. Edit: Made new title make sense >_> ....
  29. My Ipod Is Randomly Skipping Songs, Losing Data,
    regaining data, and freezing (23)
    This morning I was going to listen to some music, so I got my iPod, turned it on, and it reset (I
    hadn't had it plugged in for a while). When I got to the music, it would go through half of a
    song, then skip to the next. After doing this a couple times, it would just skip entire songs.
    It'd skip six or seven, then do half of one, then skip six or seven more. Later I looked on the
    internet for some ideas, so eventually I tried resetting it again, as instructed. This worked for a
    little bit, but then it started skipping over songs again. I reset again, and it lost....
  30. Software To Restore Data
    (15)
    Somebody knows software good to restore data. Yesterday one of my disc crash /sad.gif"
    style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> and i have information that i
    want to restore... Someone knows any program to do this??....

    1. Looking for limiting, returned, data, x, fields, sql

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for limiting, returned, data, x, fields, sql

*MORE FROM TRAP17.COM*
Similar
Create Dynamic Html/php Pages Using Simple Vb.net Code - Taking your application data, and creating a webpage for others to vie
Need Advice On Setting Up Mysql Database. - I have a huge amount of daily data updates to be inserted.
Need Help With My Database [resolved] - retrive data as a link
Very Disappointed With Data Center Migration - What do you think?
1 Terabyte Of Data On A Thumb Drive - Yes, a whole terabyte!
Eraser - Erase Your Data Permanently! For Free - A must have software
Effective Search Over Web - tips for dummies in the search fields
Getting Started With Mysql - creating tables and insert data into them.
Tropical Stream And Wheat Fields - Made with Vue 6
What Value Would I Use To Insert This Data? - Help on insertion of data to database?
What Is The Best Software - what is the best software to recovery the data
Data On My Subdomain/webspace Vanished - I need quick response!!!
Treating .csv Files As Database Data - Showing .CSV data on a web page
Free Web Hosting: (caius) [manual Data Input?] [denied] - Website Upgrade: <era.us.tp>
Php + Mysql Question! - While inserting data into MySQL, how can I know if the data I'm in
Data Structure -- Queue -- Implement Using Stack
Data Recovery Program..help!
Data Structures -- String -- Palindrome - Check if a string is a palindrome...
Data Structures -- Linked List -- Reverse - Reverse a linked list
Data Structures -- Linked List - Find the nth last element in linked list.
Loading File Into Blob Fields To Mysql
Data Recovery Software - tools for restoring deleted/formated hard drive, usb and memory
Data Base For A War Game - need data base
How Good Is This Data Cleaning Function?
Data Can Be Stored On Paper - Store GB's of electronic data on Paper
Get 30 Gb Email For Free - let us talk about , email system for huge data !
New Tech: Data Transmiting At 2.56 Terabites Per Second! - Thats like 60 dvd's per second!
C Problem: "two Or More Data Types In Declaration" - also need help with malloc
My Ipod Is Randomly Skipping Songs, Losing Data, - regaining data, and freezing
Software To Restore Data
advertisement



Limiting Returned Data To Last X Fields With Sql



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE