Android apps to use in appium android test examples

Breaking

Saturday, May 19, 2018

SQL Tutorial 8: The Select Query


SQL Tutorial 8: The Select Query

The SQL SELECT contention is used to fetch the information from a database tabular array which returns this information inwards the aeroplane of a lawsuit table. 

These lawsuit tables are called result-sets.

The basic syntax of the SELECT contention is every 2nd follows -

SELECT column1, column2, columnN FROM table_name;

SELECT * FROM table_name;

Note: If yous desire to use/Practice Select statements as well as thence nosotros must accept at to the lowest degree i tabular array amongst unopen to records...

Step 1: Create a Database
Create Database gcreddy;

Step 2: Create a Table
Before Create a tabular array outset Use/Select database...

Create tabular array abcd(
Id int, 
Name varchar(50), 
Age int, 
City varchar(50),
);  

Step 3: Enter Some Records into that Table as well as thence execute pick out statements...

Insert Into abcd
(ID, Name, Age, City)
values (1, 'Ramesh', 32, 'Pune'),
(2, 'Venkat', 25, 'Chennai'),
(3, 'Suma', 25,'Hyderabad'),
(4, 'Bhasha', 23, 'Delhi'),
(5, 'David', 27, 'Hyderabad');
-------------------
SQL> SELECT Id, Name, City FROM abcd;

It volition furnish all te records of abcd tabular array amongst ID, Name, as well as City fields only…

SQL> SELECT * FROM abcd;

It volition furnish all the records of Customers table

SQL –Where Clause 

The SQL WHERE clause is used to specify a status spell fetching the information from a unmarried tabular array or past times joining amongst multiple tables.

The WHERE clause is non exclusively used inwards the SELECT statement, but it is besides used inwards the UPDATE, DELETE statement, etc.,

Syntax:

SELECT column1, column2, columnN 
FROM table_name
WHERE [condition]

You tin halt specify a status using the comparing or logical operators like 
>, <, =, LIKE, NOT, etc.

Example:
Select Id, Name 
From abcd
Where Age > 25;

Select ID, Name, Age, City
From abcd
Where Name ='David';

AND as well as OR Conjunctive Operators:

The SQL AND & OR operators are used to combine multiple atmospheric condition to narrow information inwards an SQL statement.

The AND Operator---

Syntax:

SELECT column1, column2, columnN 
FROM table_name
WHERE [condition1] AND [condition2]...AND [conditionN];

Examples:

Select ID, Name, City
From abcd
Where Id >2 And Age > 25;

Select * From abcd
Where Id>2 And Age>=25;

The OR Operator:

Syntax:

SELECT column1, column2, columnN 
FROM table_name
WHERE [condition1] OR [condition2]...OR [conditionN]

Example:

Select Id, Name, City
From abcd
Where Id>2 Or Age>25;

Sumber http://www.gcreddy.com/

No comments:

Post a Comment