Giter Site home page Giter Site logo

alihoushy / sql Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 2 KB

The "SQL" repository serves as a comprehensive collection of my knowledge and experiences with Structured Query Language (SQL). It encompasses fundamental SQL concepts, advanced querying techniques, and practical applications.

database sql sql-server

sql's Introduction

Types of SQL Commands

Data Definition Language / DDL: It's used to construct and modify the structure of database objects in the database. Commands are: CREATE, DROP, ALTER, TRUNCATE

Data Manipulation Language / DML: It's deal with manipulating data in a database are classified, which covers the majority of SQL statements. Commands are: INSERT, UPDATE, DELETE

Data Control Language / DCL: It's a query language that allows users to retrieve and edit data held in databases. Commands are: GRANT, REVOKE

Transaction Control Language / TCL: These instructions are used in the database to manage transactions. Commands are: COMMIT, ROLLBACK, SAVEPOINT

Data Query Language / DQL: these statements are used to query the data contained in schema objects. Commands are: SELECT

Some of The Most Important SQL Commands

SELECT:  Extracts data from a database
UPDATE:  Updates data in a database
DELETE:  Deletes data from a database
INSERT INTO:  Inserts new data into a database
CREATE DATABASE:  Creates a new database
ALTER DATABASE:  Modifies a database
CREATE TABLE:  Creates a new table
ALTER TABLE:  Modifies a table
DROP TABLE:  Deletes a table
CREATE INDEX:  Creates an index (search key)
DROP INDEX:  Deletes an index

SELECT Statement

Syntax:
SELECT column1, column2, ...
FROM database_name;

Example:
SELECT Username, MobileNumber, Email FROM Users;

SELECT DISTINCT Statement

Syntax:
SELECT DISTINCT column1, column2, ...
FROM table_name;

Example:
SELECT DISTINCT Country FROM Users;
SELECT DISTINCT Country, City FROM Users;

WHERE Statement

Syntax:
SELECT column1, column2, ...
FROM table_name
WHERE condition;

Operators:
=          Equal
>          Greater than
<          Less than
>=         Greater than or equal
<=         Less than or equal
<>         Not equal
BETWEEN    Between a certain range
LIKE       Search for a pattern
IN         To specify multiple possible values for a column

Example:
SELECT * FROM Users WHERE 1;
SELECT * FROM Users WHERE UserId >= 3;
SELECT * FROM Users WHERE IsSubscribed = 1;
SELECT * FROM Users WHERE Country <> 'United States';
SELECT * FROM Users WHERE City IN ('Yerevan', 'Paris', 'Stockholm');

ORDER BY Keyword

Syntax:
SELECT column1, column2, ....
FROM table_name
ORDER BY column1, column2, ... ASC|DESC;

Example:
SELECT * FROM Users ORDER BY NationalCode;
SELECT * FROM Users ORDER BY NationalCode DESC;
SELECT * FROM Users ORDER BY NationalCode, Country DESC;
SELECT * FROM Users ORDER BY NationalCode ASC, Country DESC;

AND, OR Operator:

Syntax:
SELECT column1, column2, ...
FROM table_name
WHERE condition1 AND condition2 AND condition3 AND ...;

Example:
SELECT * FROM Users WHERE Country <> 'United States' AND IsSubscribed = 1;
SELECT * FROM Users WHERE Email LIKE '%@gmail.com' AND (Country = 'Iran' OR Country = 'United States');
SELECT * FROM Users WHERE Email IS NOT NULL AND IsSubscribed = 1;

sql's People

Contributors

alihoushy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.