Tutorial SQL

INICIO SQL Introducción a SQL Sintaxis SQL Seleccionar SQL SQL Seleccionar Distinto SQL donde SQL y, o no Orden SQL por Insertar SQL en Valores nulos de SQL Actualización SQL Eliminar SQL SQL Seleccionar parte superior SQL mínimo y máximo Recuento de SQL, Promedio, Suma SQL como Comodines de SQL SQL en SQL entre Alias ​​SQL Uniones SQL Combinación interna de SQL Unión izquierda de SQL Unión derecha de SQL Unión completa de SQL Unión automática de SQL Unión SQL Grupo SQL por SQL teniendo SQL existe SQL Cualquiera, Todo SQL Seleccionar en Insertar SQL en Seleccionar Caso SQL Funciones nulas de SQL Procedimientos almacenados de SQL Comentarios SQL Operadores SQL

Base de datos SQL

SQL Crear base de datos Base de datos de caída de SQL Base de datos de copia de seguridad de SQL Crear tabla SQL Tabla desplegable de SQL Tabla de modificación de SQL Restricciones SQL SQL no nulo SQL único Clave principal de SQL Clave foránea de SQL Comprobación SQL Valor predeterminado de SQL Índice SQL Incremento automático de SQL Fechas SQL Vistas SQL Inyección SQL Alojamiento SQL Tipos de datos SQL

Referencias SQL

Palabras clave de SQL Funciones MySQL Funciones del servidor SQL Funciones de MS Access Referencia rápida de SQL

Ejemplos SQL

Ejemplos SQL Cuestionario de SQL Ejercicios SQL Certificado SQL

Referencia rápida de SQL de W3Schools


SQL Statement Syntax
AND / OR SELECT column_name(s)
FROM table_name
WHERE condition
AND|OR condition
ALTER TABLE ALTER TABLE table_name
ADD column_name datatype

or

ALTER TABLE table_name
DROP COLUMN column_name

AS (alias) SELECT column_name AS column_alias
FROM table_name

or

SELECT column_name
FROM table_name  AS table_alias

BETWEEN SELECT column_name(s)
FROM table_name
WHERE column_name
BETWEEN value1 AND value2
CREATE DATABASE CREATE DATABASE database_name
CREATE TABLE CREATE TABLE table_name
(
column_name1 data_type,
column_name2 data_type,
column_name3 data_type,
...
)
CREATE INDEX CREATE INDEX index_name
ON table_name (column_name)

or

CREATE UNIQUE INDEX index_name
ON table_name (column_name)

CREATE VIEW CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition
DELETE DELETE FROM table_name
WHERE some_column=some_value

or

DELETE FROM table_name
(Note: Deletes the entire table!!)

DELETE * FROM table_name
(Note: Deletes the entire table!!)

DROP DATABASE DROP DATABASE database_name
DROP INDEX DROP INDEX table_name.index_name (SQL Server)
DROP INDEX index_name ON table_name (MS Access)
DROP INDEX index_name (DB2/Oracle)
ALTER TABLE table_name
DROP INDEX index_name (MySQL)
DROP TABLE DROP TABLE table_name
EXISTS IF EXISTS (SELECT * FROM table_name WHERE id = ?)
BEGIN
--do what needs to be done if exists
END
ELSE
BEGIN
--do what needs to be done if not
END
GROUP BY SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING aggregate_function(column_name) operator value
IN SELECT column_name(s)
FROM table_name
WHERE column_name
IN (value1,value2,..)
INSERT INTO INSERT INTO table_name
VALUES (value1, value2, value3,....)

or

INSERT INTO table_name
(column1, column2, column3,...)
VALUES (value1, value2, value3,....)

INNER JOIN SELECT column_name(s)
FROM table_name1
INNER JOIN table_name2
ON table_name1.column_name=table_name2.column_name
LEFT JOIN SELECT column_name(s)
FROM table_name1
LEFT JOIN table_name2
ON table_name1.column_name=table_name2.column_name
RIGHT JOIN SELECT column_name(s)
FROM table_name1
RIGHT JOIN table_name2
ON table_name1.column_name=table_name2.column_name
FULL JOIN SELECT column_name(s)
FROM table_name1
FULL JOIN table_name2
ON table_name1.column_name=table_name2.column_name
LIKE SELECT column_name(s)
FROM table_name
WHERE column_name LIKE pattern
ORDER BY SELECT column_name(s)
FROM table_name
ORDER BY column_name [ASC|DESC]
SELECT SELECT column_name(s)
FROM table_name
SELECT * SELECT *
FROM table_name
SELECT DISTINCT SELECT DISTINCT column_name(s)
FROM table_name
SELECT INTO SELECT *
INTO new_table_name [IN externaldatabase]
FROM old_table_name

or

SELECT column_name(s)
INTO new_table_name [IN externaldatabase]
FROM old_table_name

SELECT TOP SELECT TOP number|percent column_name(s)
FROM table_name
TRUNCATE TABLE TRUNCATE TABLE table_name
UNION SELECT column_name(s) FROM table_name1
UNION
SELECT column_name(s) FROM table_name2
UNION ALL SELECT column_name(s) FROM table_name1
UNION ALL
SELECT column_name(s) FROM table_name2
UPDATE UPDATE table_name
SET column1=value, column2=value,...
WHERE some_column=some_value
WHERE SELECT column_name(s)
FROM table_name
WHERE column_name operator value

Fuente: https://www.w3schools.com/sql/sql_quickref.asp