Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
73 views

SQL Quick Reference

This document provides a quick reference for common SQL statements and their syntax. It includes statements for queries, joins, aggregates, modifications and more. Each statement is listed along with its basic syntax structure for easy reference. The source is noted as a SQL reference page on the W3Schools website.

Uploaded by

bhavit07don
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views

SQL Quick Reference

This document provides a quick reference for common SQL statements and their syntax. It includes statements for queries, joins, aggregates, modifications and more. Each statement is listed along with its basic syntax structure for easy reference. The source is noted as a SQL reference page on the W3Schools website.

Uploaded by

bhavit07don
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 7

SQL 

Quick Reference From W3School


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_name2 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
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

Source : http://www.w3schools.com/sql/sql_quickref.asp
HTML 4.01 / XHTML 1.0 Reference
Ordered Alphabetically

DTD: indicates in which HTML 4.01 / XHTML 1.0 DTD the tag is allowed. S=Strict,
T=Transitional, and F=Frameset

Tag Description DTD

<!--...--> Defines a comment STF

<!DOCTYPE>  Defines the document type STF

<a> Defines an anchor STF

<abbr> Defines an abbreviation STF

<acronym> Defines an acronym STF

<address> Defines contact information for the author/owner of a document STF

<applet> Deprecated. Defines an embedded applet TF

<area /> Defines an area inside an image-map STF

<b> Defines bold text STF

<base /> Defines a default address or a default target for all links on a page STF

<basefont /> Deprecated. Defines a default font, color, or size for the text in a TF
page

<bdo> Defines the text direction STF

<big> Defines big text STF

<blockquote> Defines a long quotation STF

<body> Defines the document's body STF

<br /> Defines a single line break STF

<button> Defines a push button STF

<caption> Defines a table caption STF

<center> Deprecated. Defines centered text TF

<cite> Defines a citation STF


<code> Defines computer code text STF

<col /> Defines attribute values for one or more columns in a table  STF

<colgroup> Defines a group of columns in a table for formatting STF

<dd> Defines a description of a term in a definition list STF

<del> Defines deleted text STF

<dfn> Defines a definition term STF

<dir> Deprecated. Defines a directory list TF

<div> Defines a section in a document STF

<dl> Defines a definition list STF

<dt> Defines a term (an item) in a definition list STF

<em> Defines emphasized text  STF

<fieldset> Defines a border around elements in a form STF

<font> Deprecated. Defines font, color, and size for text TF

<form> Defines an HTML form for user input STF

<frame /> Defines a window (a frame) in a frameset F

<frameset> Defines a set of frames F

<h1> to <h6> Defines HTML headings STF

<head> Defines information about the document STF

<hr /> Defines a horizontal line STF

<html> Defines an HTML document STF

<i> Defines italic text STF

<iframe> Defines an inline frame TF

<img /> Defines an image STF

<input /> Defines an input control STF

<ins> Defines inserted text STF

<isindex> Deprecated. Defines a searchable index related to a document TF


<kbd> Defines keyboard text STF

<label> Defines a label for an input element STF

<legend> Defines a caption for a fieldset element STF

<li> Defines a list item STF

<link /> Defines the relationship between a document and an external STF
resource

<map> Defines an image-map  STF

<menu> Deprecated. Defines a menu list TF

<meta /> Defines metadata about an HTML document STF

<noframes> Defines an alternate content for users that do not support frames TF

<noscript> Defines an alternate content for users that do not support client- STF
side scripts

<object> Defines an embedded object STF

<ol> Defines an ordered list STF

<optgroup> Defines a group of related options in a select list STF

<option> Defines an option in a select list STF

<p> Defines a paragraph STF

<param /> Defines a parameter for an object STF

<pre> Defines preformatted text STF

<q> Defines a short quotation STF

<s> Deprecated. Defines strikethrough text TF

<samp> Defines sample computer code STF

<script> Defines a client-side script STF

<select> Defines a select list (drop-down list) STF

<small> Defines small text STF

<span> Defines a section in a document STF


<strike> Deprecated. Defines strikethrough text TF

<strong> Defines strong text STF

<style> Defines style information for a document STF

<sub> Defines subscripted text STF

<sup> Defines superscripted text STF

<table> Defines a table STF

<tbody> Groups the body content in a table STF

<td> Defines a cell in a table STF

<textarea> Defines a multi-line text input control STF

<tfoot> Groups the footer content in a table STF

<th> Defines a header cell in a table STF

<thead> Groups the header content in a table STF

<title> Defines the title of a document STF

<tr> Defines a row in a table STF

<tt> Defines teletype text STF

<u> Deprecated. Defines underlined text TF

<ul> Defines an unordered list STF

<var> Defines a variable part of a text STF

<xmp> Deprecated. Defines preformatted text  

You might also like