SQL Basic

SQL SELECT Statement

The most commonly used SQL command is SELECT statement. The SQL SELECT statement is used to query or retrieve data from a table in the database. A query may retrieve information from specified columns or from all of the columns in the table. To create a simple SQL SELECT Statement, you must specify the column(s) name and the table name. The whole query is called SQL SELECT Statement.

Syntax of SQL SELECT Statement:

SELECT column_list FROM table-name
[WHERE Clause]
[GROUP BY clause]
[HAVING clause]
[ORDER BY clause];
  • table-name is the name of the table from which the information is retrieved.
  • column_list includes one or more columns from which data is retrieved.
  • The code within the brackets is optional.
database table student_details;
idfirst_namelast_nameagesubjectgames
100RahulSharma10ScienceCricket
101AnjaliBhagwat12MathsFootball
102StephenFleming09ScienceCricket
103ShekarGowda18MathsBadminton
104PriyaChandra15EconomicsChess
NOTE: These database tables are used here for better explanation of SQL commands. In reality, the tables can have different columns and different data.
For example, consider the table student_details. To select the first name of all the students the query would be like:
SELECT first_name FROM student_details;
NOTE: The commands are not case sensitive. The above SELECT statement can also be written as "select first_name from students_details;"
You can also retrieve data from more than one column. For example, to select first name and last name of all the students.
SELECT first_name, last_name FROM student_details;
You can also use clauses like WHERE, GROUP BY, HAVING, ORDER BY with SELECT statement. We will discuss these commands in coming chapters.
NOTE: In a SQL SELECT statement only SELECT and FROM statements are mandatory. Other clauses like WHERE, ORDER BY, GROUP BY, HAVING are optional.

SQL Tutorial

SQL (Structured Query Language) is used to modify and access data or information from a storage area called database. This beginner online training sql tutorial website teaches you the basics of SQL code and train you how to write & program SQL queries. I will be sharing my database knowledge on SQL and help you learn programming SQL better. The concepts discussed in this SQL tutorial can be applied to most of database systems. The SQL syntax used to explain the tutorial concepts is similar to the one used in Oracle database.

SQL Intro: What is SQL?

What is SQL? SQL stands for “Structured Query Language” and can be pronounced as “SQL” or “sequel – (Structured English Query Language)”. Defined, SQL is a query language used for accessing and modifying information in the database.

SQL Database Design

IBM first developed SQL in 1970s. Also it is an ANSI/ISO standard. It has become a Standard Universal Language used by most of the relational database management systems (RDBMS). Some of the RDBMS systems are: Oracle, Microsoft SQL server, Sybase etc. Most of these have provided their own implementation thus enhancing it's feature and making it a powerful tool.

SQL Commands: Few SQL Coding Statements?

Few of the sql commands used in sql code programming are: SELECT Statement, UPDATE Statement, INSERT INTO Statement, DELETE Statement, WHERE Clause, ORDER BY Clause, GROUP BY Clause, Subquery Clauses, Joins, Views, GROUP Functions, Indexes etc.

My SQL DataBase

In a simple manner, SQL is a non-procedural, English-like language that processes data in groups of records rather than one record at a time. Few functions of SQL are:
  • store data
  • modify data
  • retrieve data
  • modify data
  • delete data
  • create tables and other database objects
  • delete data

 

How to use expressions in SQL SELECT Statement?

Expressions combine many arithmetic operators, they can be used in SELECT, WHERE and ORDER BY Clauses of the SQL SELECT Statement.
Here we will explain how to use expressions in the SQL SELECT Statement. About using expressions in WHERE and ORDER BY clause, they will be explained in their respective sections.
The operators are evaluated in a specific order of precedence, when more than one arithmetic operator is used in an expression. The order of evaluation is: parentheses, division, multiplication, addition, and subtraction. The evaluation is performed from the left to the right of the expression.
For example: If we want to display the first and last name of an employee combined together, the SQL Select Statement would be like
SELECT first_name + ' ' + last_name FROM employee;

No comments:

Post a Comment