STEPS REQUIRED FOR SQL QUERY

By kumarvikas

STEPS REQUIRED FOR SQL QUERY

Creating your own database and running SQL query is now not an enigma anymore. With zoho being launched it is now similar to playing any of the computer games.

There are certain steps which are to be followed to execute the above mentioned.

  • Create an user account in www.db.zoho.com
  • Then create a database via any of the four options displayed i.e. import via excel sheet, enter data right away, create database from template, create blank database. Then name the tables(in my case EMPLOYEE & DEPARTMENT).
  • Now run SQL query according to your need.
  • Finally execute and get the desired view.
  • If there is an error in the SQL statement,it displays the error.Through which one can correct the query statement.

According to my database views three SQL queries were run and thus three query tables(views) were generated namely JOIN, AVERAGE QUERY & CONDITIONS. But the main issue is ‘How to run a query?’ There is a myth that for running SQL query one needs to have knowledge of some kind of computer language. But zoho nullifies the myth as it is user friendly such as default select query is given for sample. Here one can write query functions and can also get SQL functions(table and column name) from the box besides query writing area.

There are three query tables one is for joining the tables and the syntax is

Select <”Table1 Column Name1”>,<” Table1 Column Name2”>,<” Table1 Column Name3”>,<” Table2 Column Name1”>,<” Table2 Column Name2”> from <”Table1”>,<”Table2”> where <”Table1”>.<”Table1 Column Name4”> = <”Table2”>.<”Table2 Column Name2”>

Where

Table1=Employee

Table2=Department

After ’where’ command column name4 elements of table1(Employee) is made equal to column name2 elements of table2(Department).this means that combination of rows satisfying above restriction are only displayed. This helps in joining two tables but with customized view. As all the details of database is not needed by everyone.

SQL query for getting average salary of the firm’s employee. Which is in average value of salary in table1(Employee).

Syntax for this SQL query is

SELECT avg < (Column Name)> from “<Table Name>”

Here column name is salary and its respective table is employee wherein the column name salary is.

This gives the average of the values of the column chosen. This is a multiple row function. Accordingly there are other functions also such as sum, max, etc.

SQL query for various restrictions such as OR, AND, wild cards is to obtain constrained view.

Syntax for this query is

Select “< Column Name1>”,”< Column Name2>”,”<Column Name3>” from “<Table Name>”where (“< Column Name 2 >”=’< Element1 of Column Name2 >’ OR “< Column Name2 >”=’<Element2 of Column Name2 >’ or “<Column Name1>” like ‘D%’) and “<Column Name 3>” < Constant

According to my DB constrained view

Column Name1=Name

Column Name2=Employee Designation

Column Name2=Salary

Table Name =Employee

Element1 of Column Name2=Clerk

Element2 of Column Name2=Cleaner

Column Name3=Salary

this give the customized view of the database. Here according to the command the three respective columns are selected. Which are encompassed through restrictions that are elements of column2 are equal to two of the identified elements of column2 itself. Means only those rows are selected which have identified elements in them. Also column name1 which is ‘name’ is subjected to constrain that name should start with ‘D’. Finally salary should be less than a constant i.e. 90000.Here OR and AND conditions acts as addition and multiplication respectively similar to the gate or BODMAS rule concept. Also whole of the OR condition is given inside round bracket because BODMAS rule needs to be followed here also. Else the function preceding ‘and’ and following ‘and’ is only considered by ‘and’ function.

In this SQL query one thing should be kept in mind is that ‘select’ command should start the query and ‘from’ command should also be used so as to locate from which table the entities are taken from.

Limitation of db.zoho.com is that only SELECT query can run.

Isn’t it easy to perform the above mentioned queries.

 

To view Query tables please view the below link:

http://db.zoho.com/ZDBDataSheetView.cc?DBID=22860000000004024&OBJID=22860000000004025

 

One Response to “STEPS REQUIRED FOR SQL QUERY”

  1. prithwis Says:

    good

Leave a Reply