Sophie

Sophie

distrib > Mandriva > 8.1 > i586 > by-pkgid > 4c03070e2af6123b13ebffa0c77a2af6 > files > 55

postgresql-tk-7.1.2-19.3mdk.i586.rpm

<html><head><title>PgAccess Tutorial</title></head>
<body bgcolor="#C0C0C0">
<h1>PgAccess Tutorial - SELECT</h1>
<img src="altern_q.jpg" border=1 align=right>
<h2>What is a query?</h2>
<em>Query</em> is the term for an SQL command which will perform an operation
on a table.  It is sometimes confusing to newcomers, as some of the operations
seem to have nothing to do with querying in the common sense of <em>asking</em>.
As we saw in the previous section, a <em>query</em> can simply copy
records from an ASCII file to a table.<p>
The PostgreSQL documentation has a complete list of <em>queries</em> that can be
used.  We'll start with the common task of selecting records with certain
characteristics.<p>
<h2>Selecting records</h2>
<img src="altern_v.jpg" border=1 align=right>
Suppose that I want to know all of the references in the sample table
<em>psyref</em> for which the word "alternative" appeared in the title.<p>
By clicking <em>Query</em>, then <em>New</em>, a <b>Query builder</b> window will
appear.  Clicking in the area below the buttons will allow the user to enter an
SQL <em>query</em>.  The specification of the <em>query</em> must be exact or
PostgreSQL will return an error message.<p>
The <em>query</em> shown will <b>SELECT</b> those records from <em>psyref</em>
that contain the word "alternative" anywhere in the <em>title</em> field.  The
'*' indicates that all of the fields are to be returned.  You might only want to
return, for instance, the <em>author</em> field if you were only interested in
which authors had used that word in the title of their work.<p>
At the right is the record that fulfils these conditions, displayed in the 
<b>Table viewer</b>.  If you wanted to save this query for use again,
clicking the <em>Save query definition</em> button will do so.  You will then
see <em>altern</em> listed under <em>Queries</em> when you return to the main
window.  By clicking the <em>Save this query as a view</em> tickbox in the 
<b>Query builder</b>, the result of your query will be saved as a 
<em>View</em> which you can access from <em>Views</em> in the main window.  
Click the <em>Close</em> button to leave the <b>Query builder</b>.<p>
<a href="index.html#tut">Back to index</a>
</body></html>