<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://script.spoken-tutorial.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=LibreOffice-Suite-Base%2FC3%2FCreate-simple-queries-in-SQL-View%2FEnglish</id>
		<title>LibreOffice-Suite-Base/C3/Create-simple-queries-in-SQL-View/English - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=LibreOffice-Suite-Base%2FC3%2FCreate-simple-queries-in-SQL-View%2FEnglish"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=LibreOffice-Suite-Base/C3/Create-simple-queries-in-SQL-View/English&amp;action=history"/>
		<updated>2026-05-15T02:02:01Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.17</generator>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php?title=LibreOffice-Suite-Base/C3/Create-simple-queries-in-SQL-View/English&amp;diff=325&amp;oldid=prev</id>
		<title>Chandrika: Created page with '{| border=1 !Visual Cue !Narration |- |Show Slide Number 1  Spoken tutorial on LibreOffice Base: Queries in SQL View  Learning Objectives  * Create Simple Queries in SQL View  * …'</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=LibreOffice-Suite-Base/C3/Create-simple-queries-in-SQL-View/English&amp;diff=325&amp;oldid=prev"/>
				<updated>2012-11-27T14:58:03Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;#039;{| border=1 !Visual Cue !Narration |- |Show Slide Number 1  Spoken tutorial on LibreOffice Base: Queries in SQL View  Learning Objectives  * Create Simple Queries in SQL View  * …&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{| border=1&lt;br /&gt;
!Visual Cue&lt;br /&gt;
!Narration&lt;br /&gt;
|-&lt;br /&gt;
|Show Slide Number 1 &lt;br /&gt;
Spoken tutorial on LibreOffice Base: Queries in SQL View&lt;br /&gt;
&lt;br /&gt;
Learning Objectives&lt;br /&gt;
&lt;br /&gt;
* Create Simple Queries in SQL View &lt;br /&gt;
* Write simple SQL&lt;br /&gt;
* Use SELECT, FROM , WHERE clauses&lt;br /&gt;
* Choose upper, lower, or mixed cases for naming fields and tables&lt;br /&gt;
|Welcome to the Spoken tutorial on LibreOffice Base.&lt;br /&gt;
 &lt;br /&gt;
In this tutorial, we will learn how to &lt;br /&gt;
&lt;br /&gt;
Create Simple Queries in SQL View	&lt;br /&gt;
&lt;br /&gt;
Write simple SQL&lt;br /&gt;
&lt;br /&gt;
Use SELECT, FROM , and WHERE clauses&lt;br /&gt;
&lt;br /&gt;
And choose upper lower or mixed cases for naming fields and tables&lt;br /&gt;
|-&lt;br /&gt;
|Show Slide Number 2&lt;br /&gt;
HSQLDB.org&lt;br /&gt;
Base runs on HSQL database engine. Stands for Hyper Structured Query Language Database Engine&lt;br /&gt;
&lt;br /&gt;
HSQLDB is open source, written in Java&lt;br /&gt;
&lt;br /&gt;
Visit http://hsqldb.org for more information&lt;br /&gt;
|Before using Base to create queries in SQL View, let us talk about LibreOffice Base.&lt;br /&gt;
&lt;br /&gt;
Base runs on the HSQL database engine &lt;br /&gt;
&lt;br /&gt;
This is an open source database engine software written in Java&lt;br /&gt;
&lt;br /&gt;
Go to http://hsqldb.org for more information on HSQLDB.&lt;br /&gt;
|-&lt;br /&gt;
|Show Slide Number 3&lt;br /&gt;
What is SQL?&lt;br /&gt;
&lt;br /&gt;
* SQL is Structured Query Language&lt;br /&gt;
&lt;br /&gt;
* Standard Language for accessing and manipulating databases&lt;br /&gt;
&lt;br /&gt;
* SQL is an ANSI (American National Standards Institute) standard&lt;br /&gt;
&lt;br /&gt;
* Some examples of DBMS using SQL: &lt;br /&gt;
LibreOffice Base, MySQL, Microsoft SQL Server, Microsoft Access, Oracle, DB2.&lt;br /&gt;
&lt;br /&gt;
Some examples of using SQL are &lt;br /&gt;
* Retrieve or SELECT data from a database&lt;br /&gt;
&lt;br /&gt;
* insert, update, delete data from a database&lt;br /&gt;
&lt;br /&gt;
* Modify database structure&lt;br /&gt;
|Okay, now let us learn about SQL.&lt;br /&gt;
&lt;br /&gt;
SQL stands for Structured Query Language&lt;br /&gt;
&lt;br /&gt;
It is a standard language for accessing and manipulating databases&lt;br /&gt;
&lt;br /&gt;
It is an internationally accepted ANSI standard.&lt;br /&gt;
&lt;br /&gt;
And so it is used in a variety of Database Management Systems or DBMS. &lt;br /&gt;
&lt;br /&gt;
Some examples are our own LibreOffice Base, MySQL, Microsoft SQL Server, Microsoft Access, Oracle, and DB2.&lt;br /&gt;
&lt;br /&gt;
The most common use of SQL is to retrieve data from a database &lt;br /&gt;
&lt;br /&gt;
which is also known as querying a database.&lt;br /&gt;
&lt;br /&gt;
SQL can also be used for inserting data into a database,  updating data or deleting data from a database.&lt;br /&gt;
&lt;br /&gt;
And we have done all of these operations using Base in our previous tutorials &lt;br /&gt;
&lt;br /&gt;
by using the very user friendly wizards and designing windows. &lt;br /&gt;
&lt;br /&gt;
But knowing the underlying query language gives us more flexibility and power to query the database.&lt;br /&gt;
&lt;br /&gt;
And SQL can also be used not only to modify data, but also to modify database and table structures&lt;br /&gt;
|-&lt;br /&gt;
|Show Slide Number 4&lt;br /&gt;
SQL Resources&lt;br /&gt;
To learn more about SQL, visit &lt;br /&gt;
* http://beginner-sql-tutorial.com/sql.htm&lt;br /&gt;
&lt;br /&gt;
* http://databases.about.com/od/sql/Structured_Query_Language_SQL.htm&lt;br /&gt;
&lt;br /&gt;
* HSQL User Guides&lt;br /&gt;
&lt;br /&gt;
Chunked HTML: http://hsqldb.org/doc/2.0/guide/  &lt;br /&gt;
All-in-one HTML: http://hsqldb.org/doc/2.0/guide/guide.html  &lt;br /&gt;
PDF: http://hsqldb.org/doc/2.0/guide/guide.pdf&lt;br /&gt;
|Since our tutorial does not cover all about SQL, here are some useful tutorials and their websites.&amp;lt;pause&amp;gt;&lt;br /&gt;
&lt;br /&gt;
HSQLDB has its own user guides.&lt;br /&gt;
&lt;br /&gt;
They can be viewed online.&lt;br /&gt;
&lt;br /&gt;
Or they can be downloaded and saved into your computer as a PDF file.&lt;br /&gt;
&lt;br /&gt;
Okay, let us learn some SQL now. We will open our familiar Library database example.&lt;br /&gt;
|-&lt;br /&gt;
|Open Library database in base, if not already open&lt;br /&gt;
In the base main window, click on the Queries list on the left panel &lt;br /&gt;
&lt;br /&gt;
And then click on the ‘Create Query in SQL View’&lt;br /&gt;
|Let’s open our Library database.&lt;br /&gt;
&lt;br /&gt;
Now, let us click on the Queries list on the left panel &lt;br /&gt;
&lt;br /&gt;
and then click on ‘Create Query in SQL View’.&lt;br /&gt;
|-&lt;br /&gt;
|Show cursor movement appropriately.&lt;br /&gt;
&lt;br /&gt;
(zooming or larger fonts preferred,&lt;br /&gt;
Use the same upper or lower cases. Typing these with mistakes in Cases, will return errors.)&lt;br /&gt;
&lt;br /&gt;
SELECT * FROM Books &lt;br /&gt;
&lt;br /&gt;
Show cursor movement appropriately.&lt;br /&gt;
&lt;br /&gt;
Click on edit menu, click on Run Query.&lt;br /&gt;
&lt;br /&gt;
Point cursor over the top area.&lt;br /&gt;
&lt;br /&gt;
Click on Save icon, click ok.&lt;br /&gt;
|Now we see a blank window titled Query Design &lt;br /&gt;
&lt;br /&gt;
and this is where we will type in our queries in SQL.&lt;br /&gt;
&lt;br /&gt;
Let us write our first simple query. And that is:&lt;br /&gt;
&lt;br /&gt;
Get information about all books in the library. Simple.&lt;br /&gt;
&lt;br /&gt;
Any retrieval needs to use a SELECT keyword.&lt;br /&gt;
&lt;br /&gt;
So we will write our query as &lt;br /&gt;
&lt;br /&gt;
SELECT * FROM Books &lt;br /&gt;
&lt;br /&gt;
Here Books is the table name. &lt;br /&gt;
&lt;br /&gt;
Notice the capital B in books. &lt;br /&gt;
&lt;br /&gt;
We will faithfully follow the table or column names we used earlier.&lt;br /&gt;
&lt;br /&gt;
And * is a wild card.  Here it means, get all the fields or columns from the Books table.&lt;br /&gt;
&lt;br /&gt;
Now let us execute or run it. Click on Edit menu and then click on Run Query.&lt;br /&gt;
&lt;br /&gt;
Now we see a top panel with a list of records on books.&lt;br /&gt;
&lt;br /&gt;
We can save this query or any query we write and give them descriptive names. &lt;br /&gt;
&lt;br /&gt;
So there is our first simple query! &lt;br /&gt;
|-&lt;br /&gt;
|Show Slide Number 5&lt;br /&gt;
HSQL Tips and Notes&lt;br /&gt;
&lt;br /&gt;
1. HSQLDB is case sensitive with its Database object names, such as tables, column names.&lt;br /&gt;
&lt;br /&gt;
2. Table name “Books” is not the same as “books”.&lt;br /&gt;
&lt;br /&gt;
3. For convenience, use all upper cases or all lower cases. Example: BOOKS, members, etc.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. But if better readability is important, then use mixed cases. Example: BooksIssued, ReturnDate&lt;br /&gt;
&lt;br /&gt;
5. Keywords like SELECT, FROM can be of any case, but be uniform for better readability&lt;br /&gt;
|Here are some tips:&lt;br /&gt;
&lt;br /&gt;
HSQLDB is case sensitive with its Database object names, such as tables and column names.&lt;br /&gt;
&lt;br /&gt;
Meaning, Table name “Books” with a Capital B is not the same as “books” with a small b.&lt;br /&gt;
&lt;br /&gt;
But for convenience we can use all upper cases or all lower cases. &lt;br /&gt;
&lt;br /&gt;
For example: BOOKS in capital letters, or members in small letters, etc.&lt;br /&gt;
&lt;br /&gt;
But using mixed cases, can be easy to read and understand. For example: BooksIssued, with a capital B and I. &lt;br /&gt;
&lt;br /&gt;
Or ReturnDate with a capital R and D.&lt;br /&gt;
&lt;br /&gt;
So, we have to use the table names and column names just the way they are created.&lt;br /&gt;
&lt;br /&gt;
For SQL keywords like SELECT, we can use any case or mix cases. &lt;br /&gt;
&lt;br /&gt;
But let us be uniform in our usage for better readability.&lt;br /&gt;
&lt;br /&gt;
In our examples, we will use all upper cases for keywords.&lt;br /&gt;
|-&lt;br /&gt;
|In the Base query window,&lt;br /&gt;
&lt;br /&gt;
Highlight all the text in the bottom panel, and over write by typing:&lt;br /&gt;
&lt;br /&gt;
SELECT Title, Author FROM Books&lt;br /&gt;
Click on Run Query icon.&lt;br /&gt;
&lt;br /&gt;
Show cursor movement.&lt;br /&gt;
|Now, onto our next query. &lt;br /&gt;
&lt;br /&gt;
We can type this query in a new window, or we can overwrite it on the previous query. &lt;br /&gt;
&lt;br /&gt;
For now, let us overwrite it on the previous query.&lt;br /&gt;
&lt;br /&gt;
Let us retrieve specific columns from the Books table. &lt;br /&gt;
&lt;br /&gt;
SELECT Title, Author FROM Books&lt;br /&gt;
&lt;br /&gt;
And run the query. We can also use the Run Query icon below the file menu bar &lt;br /&gt;
&lt;br /&gt;
or use the keyboard shortcut F5.&lt;br /&gt;
&lt;br /&gt;
And there are our records with only those columns that we needed.&lt;br /&gt;
|-&lt;br /&gt;
|Highlight all the text in the bottom panel, and over write by typing:&lt;br /&gt;
&lt;br /&gt;
SELECT * FROM Books WHERE Publisher = 'Cambridge'&lt;br /&gt;
&lt;br /&gt;
Show cursor movement appropriately &lt;br /&gt;
&lt;br /&gt;
Click query icon.&lt;br /&gt;
&lt;br /&gt;
Show cursor movement appropriately&lt;br /&gt;
|Okay. Let us move on.&lt;br /&gt;
&lt;br /&gt;
Let us introduce conditions or criteria for our query.&lt;br /&gt;
&lt;br /&gt;
We will retrieve only those books published by Cambridge.&lt;br /&gt;
&lt;br /&gt;
And so, our query is&lt;br /&gt;
&lt;br /&gt;
SELECT * FROM Books WHERE Publisher = 'Cambridge'&lt;br /&gt;
&lt;br /&gt;
Notice that we have introduced a new keyword WHERE.&lt;br /&gt;
&lt;br /&gt;
Followed by a condition, where we say Publisher equals Cambridge&lt;br /&gt;
&lt;br /&gt;
Let us run our query now &lt;br /&gt;
&lt;br /&gt;
and we see only those books for which the publisher is Cambridge.&lt;br /&gt;
|-&lt;br /&gt;
|Highlight all the text in the bottom panel, and over write by typing:&lt;br /&gt;
&lt;br /&gt;
SELECT * FROM Books WHERE Publisher = 'Cambridge' AND PublishedYear &amp;gt; 1975&lt;br /&gt;
&lt;br /&gt;
Show cursor movement appropriately&lt;br /&gt;
&lt;br /&gt;
Click Run Query icon&lt;br /&gt;
&lt;br /&gt;
Show cursor movement appropriately&lt;br /&gt;
|And so we can have any number of conditions or criteria in a query.&lt;br /&gt;
&lt;br /&gt;
Let us write a query with two conditions.&lt;br /&gt;
&lt;br /&gt;
Let us retrieve only those books published by Cambridge and only those that were published after the year 1975.&lt;br /&gt;
&lt;br /&gt;
And our query is:&lt;br /&gt;
&lt;br /&gt;
SELECT * FROM Books WHERE Publisher = 'Cambridge' AND PublishedYear &amp;gt; 1975&lt;br /&gt;
&lt;br /&gt;
And we see two conditions after the WHERE keyword or clause.&lt;br /&gt;
&lt;br /&gt;
Notice that they are put together using ‘AND’. Here ‘AND’ is called a logical operator, &lt;br /&gt;
&lt;br /&gt;
and here it serves to combine conditions. ‘OR’ is another logical operator.&lt;br /&gt;
&lt;br /&gt;
Explore these by using them in the above query later.&lt;br /&gt;
&lt;br /&gt;
Let us now run the query and see the results at the top. &lt;br /&gt;
&lt;br /&gt;
There, these are the books that met our conditions.&lt;br /&gt;
|-&lt;br /&gt;
|Highlight all the text in the bottom panel, and over write by typing:&lt;br /&gt;
&lt;br /&gt;
SELECT * FROM Books WHERE Publisher IN ( 'Cambridge', 'Oxford')&lt;br /&gt;
&lt;br /&gt;
Click Run Query icon.&lt;br /&gt;
|Okay, let us also learn another way to include multiple conditions.&lt;br /&gt;
&lt;br /&gt;
How can we get a list of only those books for which the publisher is Cambridge or Oxford or both?&lt;br /&gt;
&lt;br /&gt;
And here is our query:&lt;br /&gt;
&lt;br /&gt;
SELECT * FROM Books WHERE Publisher IN ( 'Cambridge', 'Oxford')&lt;br /&gt;
&lt;br /&gt;
Notice the new keyword ‘IN’. &lt;br /&gt;
&lt;br /&gt;
It helps to combine conditions based on a single column, in this case, the Publisher.&lt;br /&gt;
&lt;br /&gt;
And notice the results now.&lt;br /&gt;
|-&lt;br /&gt;
|Show Slide Number 5&lt;br /&gt;
assignment:&lt;br /&gt;
Write and test SQL queries for the following:&lt;br /&gt;
&lt;br /&gt;
1. Get information about all the members in the Library.&lt;br /&gt;
2. Get a list of all book titles which are priced more than Rs 150&lt;br /&gt;
3. Get a list of books which were authored by William Shakespeare or John Milton?&lt;br /&gt;
|Here is an assignment:&lt;br /&gt;
&lt;br /&gt;
Write and test your SQL queries for the following:&lt;br /&gt;
&lt;br /&gt;
1. Get information about all the members in the Library.&lt;br /&gt;
2. Get a list of all book titles which are priced more than Rs 150&lt;br /&gt;
3. Get a list of books which were written by William Shakespeare or John Milton&lt;br /&gt;
&lt;br /&gt;
Let us learn more about SQL in the next tutorial.&lt;br /&gt;
|-&lt;br /&gt;
|Show Slide Number 6&lt;br /&gt;
Summary&lt;br /&gt;
&lt;br /&gt;
Create Simple Queries in SQL View &lt;br /&gt;
&lt;br /&gt;
Write simple SQL&lt;br /&gt;
&lt;br /&gt;
Use SELECT, FROM , WHERE clauses&lt;br /&gt;
&lt;br /&gt;
Choose upper, lower, or mixed cases for naming fields and tables&lt;br /&gt;
|This brings us to the end of this tutorial on Queries in SQL View in LibreOffice Base&lt;br /&gt;
&lt;br /&gt;
To summarize, we learned how to: &lt;br /&gt;
&lt;br /&gt;
Create Simple Queries in SQL View	&lt;br /&gt;
&lt;br /&gt;
Write simple SQL&lt;br /&gt;
&lt;br /&gt;
Use SELECT, FROM , and WHERE clauses&lt;br /&gt;
&lt;br /&gt;
And choose upper, lower, or mixed cases for naming fields and tables.&lt;br /&gt;
|-&lt;br /&gt;
|Acknowledgement Slide&lt;br /&gt;
|Spoken Tutorial Project is a part of the Talk to a Teacher project, supported by the National Mission on Education through ICT, MHRD, Government of India. This project is co-ordinated by http://spoken-tutorial.org. More information on the same is available at the following link http://spoken-tutorial.org/NMEICT-Intro. This script has been contributed by Priya Suresh, DesiCrew Solutions Pvt Ltd, signing off. Thanks for joining.&lt;br /&gt;
|-&lt;/div&gt;</summary>
		<author><name>Chandrika</name></author>	</entry>

	</feed>