tarea

Páginas: 24 (5796 palabras) Publicado: 18 de septiembre de 2014
On this page, you will find SQL syntax for some of the most important SQL commands. These below SQL Syntaxes will be suitable for quick reference.

SELECT [hint][DISTINCT] select_list
FROM table_list

[WHERE conditions]
[GROUP BY group_by_list]
[HAVING search_conditions]

[ORDER BY order_list [ASC DESC] ]
[FOR UPDATE for_update_options]

SQL Select Statement

SELECT "column name"FROM "table name"

Example:
Select salary from emp;

SQL Where

SELECT "column name"
FROM "table name"
WHERE "condition"

Example:
Select salary from emp
Where salary > 2000

SQL Distinct

SELECT DISTINCT "column name"
FROM "table name"

Example:
Select DISTINCT name from emp;

SQL And/Or

SELECT "column name"
FROM "table name"
WHERE "condition"
{[ANDOR] "condition"}+Example:
SELECT salary
FROM emp
WHERE Salary > 1000
OR (Salary 275)

SQL Between

SELECT "column name"
FROM "table name"
WHERE "column name" BETWEEN 'value1' AND 'value2'

Example:
SELECT *
FROM emp
WHERE Date BETWEEN 'Jan-01-1999' AND 'Jan-15-1999'

SQL In

SELECT "column name"
FROM "table name"
WHERE "column name" IN ('value1', ‘value2’ ...)

Example:
SELECT *
FROMemp
WHERE last_name IN ('sharma', 'dhall')

SQL Like

SELECT "column name"
FROM "table name"
WHERE "column name" LIKE {PATTERN}

Example:
SELECT *
FROM emp
WHERE last_name LIKE '%EN%'

SQL Order By

SELECT "column name"
FROM "table name"
[WHERE "condition"]
ORDER BY "column name" [ASC, DESC]

Example:
SELECT name, Salary
FROM emp
ORDER BY name DESC

SQL Count

SELECTCOUNT ("column name")
FROM "table name"

Example: 
SELECT COUNT (salary)
FROM emp

SELECT * FROM Table;

In the above query, SELECT and FROM are SQL keywords, * is a wildcard which means “all columns”

According to wikipedia Commonly available SQL keywords related to SELECT include:

“En la consulta anterior, SELECT y FROM son palabras clave de SQL, * es un comodín que significa"todas las columnas" 

Según wikipedia palabras clave comúnmente disponibles de SQL relacionados con SELECT incluir: ”
1. FROM is used to indicate from which tables the data is to be taken, as well as how the tables JOIN to each other.
2. WHERE is used to identify which rows to be retrieved, or applied to GROUP BY. WHERE is evaluated before the GROUP BY.
3. GROUP BY is used to combine rows withrelated values into elements of a smaller set of rows.
4. HAVING is used to identify which of the "combined rows" (combined rows are produced when the query has a GROUP BY keyword or when the SELECT part contains aggregates), are to be retrieved. HAVING acts much like a WHERE, but it operates on the results of the GROUP BY and hence can use aggregate functions.
5. ORDER BY is used to identifywhich columns are used to sort the resulting data.

“1. FROM se utiliza para indicar a partir de qué tablas los datos van a ser tomadas, así como la forma de las tablas de combinación entre sí. 
2. WHERE se utiliza para identificar las filas que se va a recuperar, o aplicarse a GROUP BY. WHERE se evalúa antes de que el GROUP BY. 
3. GROUP BY se utiliza para combinar filas con valoresrelacionados a los elementos de un conjunto más pequeño de filas. 
4. HAVING se utiliza para identificar cuál de las "filas combinadas" (filas combinadas se produce cuando la consulta tiene un GROUP BY palabra clave o cuando la parte SELECT contiene agregados), se van a recuperar. HAVING actúa como un WHERE, pero opera en los resultados de la GROUP BY y por lo tanto puede usar las funciones de agregado. 5. ORDER BY se utiliza para identificar las columnas que se utiliza para ordenar los datos resultantes. ”

Returning a Single Column from a table

The syntax is as follows:
SELECT Column FROM Table;

Oracle uses the ANSI standard concatenation operator, . Because this operator is reserved for string concatenation, the operands don't need to be cast to a string type—they'll be converted...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Mi tarea Tu tarea
  • tarea tarea
  • Tarea Tarea
  • Tarea
  • Tarea
  • Tarea
  • Tarea
  • Tarea

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS