Query help you to perform searching in the database and returning the matching record from it. It can be run on multiple tables as well. You can filter the results using criteria and display specific results. OO base provides an option to choose criteria for your search. So now let’s start how to use the query in OO Base for Retrieve data using Query.
A query is a command of DBMS system that retrieves data from the database table.
OO Base provides three ways to perform a query:
So let’s start with query creation using wizard for Retrieve data using Query. The first way to Retrieve data using Query is query creation using wizard.
As you know wizard is a step by step process to complete a specific task. You can perform query using wizard in OO Base. The steps are as following:
The another way to perform query in Retrieve data using Query is Query using design.
Follow the given steps to perform query in design view:
Now in the next section of Retrieve data using Query we will talk about Create Query in SQL View.
This option allows using SQL command to display the results. As you are familiar with DDL and DML commands in OO base, Select is one type of DML command that allows displaying records from a table. Follow some OO base typing etiquettes while using SQL view for Retrieve data using Query. So let’s see the complete process of how to use select in SQL view:
The syntax of select is something like this:
select */columns_list from table_name where conditions
In the above SQL statement,
To understand the SQL view for Retrieve data using Query consider the following.
There are four ways you can use select query:
Now let’s see all of these one by one to understand Retrieve data using Query.
Whenever you want to fetch all records from table you can use this option. The syntax and example are as following:
select * from "emp"
All records with limited columns
Whenever you want to fetch all records with limited columns from table use specific column names with select clause. Consider the following example:
select "empcode","ename","job" from "emp"
Limited records with all columns
Whenever you want to access all columns * is used after select clause and to limit records, where condition is used. With where condition some relational operators are used as per the requirement. These operators are:
select * from "emp" where "empno"<1020
select * from "emp" where "empno">1015
select * from "emp" where "job"<>'MANAGER'
select * from "emp" where "ename" like 'M%T'
select * from "emp" where "ename" is null
select * from "emp" where "ename" is not null
Limited records with limited columns
Specify the column names after select and use where condition to restrict them.
selected "empno","ename" from "emp" where "ename"='MOHIT'
To sort records using SQL order by clause is added to your query. Observe following query:
select * from "emp" order by "ename"
Sometimes you need to group records which is our next topic for Retrieve data using Query.
To group records group by clause is used. Observe the following query:
select "job",count("job") from "emp" group by "job"
4 videos|28 docs|8 tests
|
|
Explore Courses for Class 10 exam
|