]> granicus.if.org Git - postgresql/commitdiff
Add info about selecting a random row.
authorBruce Momjian <bruce@momjian.us>
Wed, 28 May 2003 04:35:28 +0000 (04:35 +0000)
committerBruce Momjian <bruce@momjian.us>
Wed, 28 May 2003 04:35:28 +0000 (04:35 +0000)
doc/FAQ
doc/src/FAQ/FAQ.html

diff --git a/doc/FAQ b/doc/FAQ
index c188796c0eb38c6632f23b727746aa57aef47735..234267d2814478b6d77a08f1189bd121bec9aa88 100644 (file)
--- a/doc/FAQ
+++ b/doc/FAQ
@@ -1,7 +1,7 @@
 
                 Frequently Asked Questions (FAQ) for PostgreSQL
                                        
-   Last updated: Mon May 26 15:25:04 EDT 2003
+   Last updated: Wed May 28 00:35:16 EDT 2003
    
    Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us)
    
@@ -58,7 +58,7 @@
                            Operational Questions
                                       
    4.1) What is the difference between binary cursors and normal cursors?
-   4.2) How do I SELECT only the first few rows of a query?
+   4.2) How do I SELECT only the first few rows of a query? A random row?
    4.3) How do I get a list of tables or other things I can see in psql?
    4.4) How do you remove a column from a table, or change it's data
    type?
     
    See the DECLARE manual page for a description.
    
-    4.2) How do I SELECT only the first few rows of a query?
+    4.2) How do I SELECT only the first few rows of a query? A random row?
     
    See the FETCH manual page, or use SELECT ... LIMIT....
    
    evaluate only the first few records requested, or the entire query may
    have to be evaluated until the desired rows have been generated.
    
+   To SELECT a random row, use:
+    SELECT col
+    FROM tab
+    ORDER BY random()
+    LIMIT 1;
+
     4.3) How do I get a list of tables or other things I can see in psql?
     
    You can read the source code for psql in file
index c63696aa5872fa592f5de6191752c3ff9cb56566..23e7c92d06b7227438f77b2fd5cd90fdae52b29e 100644 (file)
@@ -10,7 +10,7 @@
   alink="#0000ff">
     <H1>Frequently Asked Questions (FAQ) for PostgreSQL</H1>
 
-    <P>Last updated: Mon May 26 15:25:04 EDT 2003</P>
+    <P>Last updated: Wed May 28 00:35:16 EDT 2003</P>
 
     <P>Current maintainer: Bruce Momjian (<A href=
     "mailto:pgman@candle.pha.pa.us">pgman@candle.pha.pa.us</A>)<BR>
@@ -83,7 +83,7 @@
     <A href="#4.1">4.1</A>) What is the difference between binary
     cursors and normal cursors?<BR>
      <A href="#4.2">4.2</A>) How do I <SMALL>SELECT</SMALL> only the
-    first few rows of a query?<BR>
+    first few rows of a query?  A random row?<BR>
      <A href="#4.3">4.3</A>) How do I get a list of tables or other
     things I can see in <I>psql</I>?<BR>
      <A href="#4.4">4.4</A>) How do you remove a column from a
     description.</P>
 
     <H4><A name="4.2">4.2</A>) How do I <SMALL>SELECT</SMALL> only the
-    first few rows of a query?</H4>
+    first few rows of a query?  A random row?</H4>
 
     <P>See the <SMALL>FETCH</SMALL> manual page, or use
     <SMALL>SELECT</SMALL> ... <SMALL>LIMIT</SMALL>....</P>
     records requested, or the entire query may have to be evaluated
     until the desired rows have been generated.</P>
 
+    <P>To <SMALL>SELECT</SMALL> a random row, use:
+<PRE>
+    SELECT col
+    FROM tab
+    ORDER BY random()
+    LIMIT 1;
+</PRE>
+
     <H4><A name="4.3">4.3</A>) How do I get a list of tables or other
     things I can see in <I>psql</I>?</H4>