SQL Syntax Examples: Difference between revisions

From Free Knowledge Base- The DUCK Project
Jump to navigation Jump to search
mNo edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
A list of SQL statements to serve as examples of syntax.
== Primary 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
== Examples ==
== Examples ==


Line 6: Line 21:
# DESCRIBE TABLE customer;
# DESCRIBE TABLE customer;
# SELECT usertable.UserName, Posts.PostID FROM usertable LEFT JOIN Posts ON usertable.UserID = Posts.UserID ORDER BY usertable.UserName;  
# SELECT usertable.UserName, Posts.PostID FROM usertable LEFT JOIN Posts ON usertable.UserID = Posts.UserID ORDER BY usertable.UserName;  
# SELECT DISTINCT Name FROM forumusers;


== Other Pages with SQL Examples ==
== Other Pages with SQL Examples ==


* [[Krissy's MySQL Command Reference with Examples]]
* <big>[[Krissy's MySQL Command Reference with Examples]]</big>
* [[More MySQL Examples]]
* <big>[[More MySQL Examples]]</big>
* [[Create Table Examples for MySQL]]
* [[Create Table Examples for MySQL]]
* [[MySQL database Access and Users]]
* [[MySQL database Access and Users]]
* [[Data Import Example for MySQL]]
* [[Data Import Example for MySQL]]
* [[Adding MySQL Users]]
* [[Adding MySQL Users]]

Latest revision as of 08:44, 1 July 2017

A list of SQL statements to serve as examples of syntax.

Primary 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

Examples

  1. SELECT * FROM customers;
  2. SELECT grade, age, reportcategory FROM students WHERE classroom = 3;
  3. SELECT username FROM usertable WHERE username like "%icol%";
  4. DESCRIBE TABLE customer;
  5. SELECT usertable.UserName, Posts.PostID FROM usertable LEFT JOIN Posts ON usertable.UserID = Posts.UserID ORDER BY usertable.UserName;
  6. SELECT DISTINCT Name FROM forumusers;

Other Pages with SQL Examples